Libraries and settings

1. Import and format carbon chemistry data

Seasonality

  • Winter: Jan-Mar
  • Spring: Apr-Jun
  • Summer: Jul-Sep
  • Fall: Oct-Dec
  • Wet: May - October
  • Dry: November - April

2. Check data available

2.1 Locations (all samples)

Figure Supp: Map of the sites where individual samples were collected

Notes: * Check location of individual SiteIDs

2.2 Average GPS point location

- Figure 1: Stations

Figure 1: Location of the permanent sampling stations along the Florida Reef Tract. The black boxes delimitate the biogeographical regions. The color of the stations represents their position along the shelf.

2.3 Number of samples

By zone and location

Sub_region Inshore Mid channel Offshore Oceanic
BB 83 75 82
UK 105 70 110 36
MK 124 126 127 78
LK 133 136 168 85

By year and sub_region

Samples collected each year
Sub_region 2010 2011 2012 2014 2015 2016 2017 2018 2019 2020 2021
BB 4 11 3 6 30 36 30 35 24 24 37
UK 7 15 3 8 45 51 42 44 30 31 45
MK 15 39 9 11 55 66 53 56 43 44 64
LK 18 51 9 11 58 72 59 76 53 45 70

By climatological season and region

Samples collected in each season
Sub_region Fall Spring Winter Summer
LK 149 133 123 117
MK 132 119 95 109
UK 88 81 72 80
BB 68 60 52 60

By Month-year

Samples collected by year-month
2010 2011 2012 2014 2015 2016 2017 2018 2019 2020 2021 Months
38 37 19 6 35 January
16 22 37 February
24 2 38 35 33 March
23 38 15 35 37 April
38 16 28 May
20 24 38 38 35 8 June
37 38 17 36 25 July
19 38 34 10 August
38 38 36 September
28 38 18 38 36 October
37 35 37 November
25 36 37 37 35 December

By Season-year

Samples collected by year-month
2010 2011 2012 2014 2015 2016 2017 2018 2019 2020 2021 Season
24 16 24 76 72 52 6 35 37 Winter
20 47 76 38 38 66 35 73 Spring
75 76 36 38 72 34 35 Summer
53 36 37 35 38 55 37 75 71 Fall

By Month-region

Samples collected by month-location
Sub_region Zone Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
BB Inshore 7 4 7 9 4 8 10 4 6 8 6 10
BB Mid channel 7 3 6 9 4 5 10 4 6 7 6 8
BB Offshore 7 4 7 9 4 8 10 4 6 8 6 9
UK Inshore 10 4 9 13 6 8 13 6 7 9 9 11
UK Mid channel 7 2 7 5 3 9 9 3 6 6 5 8
UK Offshore 12 3 9 11 5 12 14 5 9 11 8 11
UK Oceanic 3 2 4 3 1 5 4 1 3 4 2 4
MK Inshore 9 6 9 12 8 15 12 8 9 13 9 14
MK Mid channel 9 7 11 12 8 13 13 8 9 13 9 14
MK Offshore 10 6 11 13 7 13 13 8 9 13 9 15
MK Oceanic 6 4 7 6 4 8 8 6 6 8 5 10
LK Inshore 11 8 12 12 7 16 9 10 9 15 9 15
LK Mid channel 12 9 12 12 7 15 10 11 9 15 9 15
LK Offshore 18 7 13 14 10 18 13 15 12 19 12 17
LK Oceanic 7 6 8 8 4 10 5 8 6 9 5 9

Per station during all sampling time

Samples collected in SiteIDs
2010 2011 2012 2014 2015 2016 2017 2018 2019 2020 2021 SiteID Sub_region Zone
2 5 1 1 5 6 5 6 4 4 6 1 BB Inshore
2 5 1 1 5 6 5 6 4 4 6 3 BB Offshore
1 3 1 5 6 5 4 2 3 4 4 UK Inshore
1 3 1 1 5 6 5 4 2 3 4 5 UK Inshore
2 2 1 1 5 5 4 4 3 3 4 5.5 UK Mid channel
2 3 1 5 5 4 4 3 3 5 6 UK Offshore
1 4 1 1 5 5 4 4 3 3 5 6.5 UK Oceanic
2 4 1 1 5 6 5 5 4 4 5 10 MK Inshore
1 3 1 1 5 6 5 4 4 4 6 13 MK Inshore
2 5 1 5 6 3 6 4 4 6 7 MK Inshore
2 3 1 1 5 6 5 5 4 4 6 11 MK Mid channel
1 2 1 1 5 6 5 5 4 4 6 14 MK Mid channel
2 4 1 1 5 6 5 6 4 4 6 8 MK Mid channel
1 4 1 1 5 6 5 6 4 4 6 12 MK Offshore
2 5 1 5 6 5 6 4 4 6 9 MK Offshore
2 4 1 1 5 6 5 4 3 4 5 9.5 MK Oceanic
2 5 1 1 5 6 5 6 4 3 5 16 LK Inshore
2 5 1 5 6 4 6 4 4 6 19 LK Inshore
2 5 1 1 5 6 5 7 5 4 6 24 LK Inshore
2 5 1 1 5 6 5 7 4 4 5 17 LK Mid channel
2 5 1 1 5 6 5 6 4 4 6 20 LK Mid channel
1 5 1 1 5 6 5 7 5 4 6 23 LK Mid channel
2 5 1 1 5 6 5 7 4 4 6 18 LK Offshore
1 4 1 5 6 5 5 4 4 6 21LK LK Offshore
1 2 1 1 5 6 5 7 5 4 6 22 LK Offshore
2 5 1 1 4 6 5 5 4 3 6 21.5 LK Oceanic
1 5 1 1 4 6 5 6 5 3 6 22.5 LK Oceanic
1 1 1 5 6 5 6 4 4 6 2 BB Mid channel
3 1 1 5 6 5 5 4 4 6 15 MK Offshore
2 1 1 5 6 5 4 4 4 6 15.5 MK Oceanic
1 5 6 5 6 4 4 7 EK_IN BB Inshore
1 5 6 5 5 4 4 6 EK_MID BB Mid channel
1 5 6 5 6 4 4 6 EK_OFF BB Offshore
1 5 6 5 6 4 4 5 UK_IN UK Inshore
1 5 6 5 5 4 4 6 UK_MID UK Mid channel
1 5 6 5 6 4 4 6 UK_OFF UK Offshore
5 6 5 7 5 4 6 MR UK Offshore
5 6 5 7 5 4 6 WS LK Offshore

Flag extreme events

Three extreme weather events can be observed in the data and associated with abnormal conditions:

  • A cold snap that caused coral mortality in March 2010 (Manzello et al. 2012)
  • Extreme precipitation that reduced salinity in October 2011 (Manzello et al. 2012)
  • Abnormally low pH in July, Sept and Nov 2019 (not know reason)

These data can be seen / flagged / filtered using the “Extreme” column.

# Label and filter extreme events
  FLK.data$Extreme<-as.factor(FLK.data$Extreme)
    summary(FLK.data$Extreme)
## ColdMortality        Low_pH    LowSalinty        Normal 
##            24           109            28          1377
  FLK.data_filtered<-FLK.data[FLK.data$Extreme=="Normal",]

3 Temperature and salinity impacts on carbonate chemistry

Temperature vs salinity

Zone

Tep_Sal_Sea<- ggplot(FLK.data) + MyTheme+
  geom_point(aes (Temperature_C, BestSalinity, fill=Season, shape=Zone),
             alpha=0.7, size=0.8)+
  # geom_smooth(aes(Temperature_C, BestSalinity, colour=Sub_region),
  #             linetype=1, method = "lm", se=F)+
  geom_smooth(aes(Temperature_C, BestSalinity),
              linetype=1, method = "lm", colour="black")+
  #Precipitation_fill+
  Season_fill+
  Zone_shapes4+
  guides(shape = "none")+
  scale_y_continuous(#limits = c(1700, 2400),
                     expand = c(0.3, 0.02),
                     name=expression(Salinity))+
  scale_x_continuous(#limits = c(1700, 2400),
                     expand = c(0.02, 0.02),
                     name=(expression("Temperature"~(degree*C))))+
 theme(axis.text.x = element_text(angle = 0))
Tep_Sal_Sea + facet_grid(~Zone)

#ggsave(file="FLK_results/Temp_Sal.svg", plot=Tep_Sal_Sea, dpi = 300, width=5, height=5)
  • Mean temperature in the data set
#MeanTem<-mean(FLK.data[FLK.data$Zone=="Oceanic",]$Temperature_C)
MeanTem<-mean(FLK.data$Temperature_C)
sdTem<-sd(FLK.data$Temperature_C)

Tem<-paste("Mean Tem = ", round(MeanTem, digits=3),
           "(", round(sdTem, digits=3), "sd)")
Tem
## [1] "Mean Tem =  27.139 ( 2.955 sd)"
  • Tem-Sal: Model II OLS regressions - only zone
TS_coef_OLS <- FLK.data %>%
                group_by(Zone) %>%
                do({model = lm(BestSalinity~Temperature_C, data=.)  # model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
#TS_coef_OLS

kable(as.data.frame(TS_coef_OLS[,1:9], format = "markdown"), 
      caption = "Table: Salinity vs Temperature linear regressions by zone",
      digits = 3)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table: Salinity vs Temperature linear regressions by zone
Zone term estimate std.error statistic p.value r.squared adj.r.squared sigma
Inshore (Intercept) 34.798 0.388 89.776 0.000 0.022 0.020 1.078
Inshore Temperature_C 0.046 0.014 3.190 0.002 0.022 0.020 1.078
Mid channel (Intercept) 36.416 0.326 111.832 0.000 0.004 0.002 0.714
Mid channel Temperature_C -0.015 0.012 -1.295 0.196 0.004 0.002 0.714
Offshore (Intercept) 37.949 0.282 134.547 0.000 0.092 0.090 0.563
Offshore Temperature_C -0.072 0.010 -6.995 0.000 0.092 0.090 0.563
Oceanic (Intercept) 39.049 0.449 86.979 0.000 0.194 0.190 0.541
Oceanic Temperature_C -0.112 0.016 -6.879 0.000 0.194 0.190 0.541
#write.csv(TS_coef_OLS, "FLK_results/Tem_Sal.csv")
  • Are TA vs Sal slopes different in each zone?
# All data 
Te_sal_model<-lm(BestSalinity ~ Temperature_C * Zone, data=FLK.data)
    anova(Te_sal_model)
    #summary(Te_sal_model)
    # Te_sal_aov<-aov(Te_sal_model)
    # 
    # TeS_PostH<-TukeyHSD(Te_sal_aov, c("Zone"), 
    #                    ordered = TRUE)
    # TeS_PostH
    
    m.lst <- lstrends(Te_sal_model, "Zone", var="Temperature_C")
    pairs(m.lst)
##  contrast               estimate     SE   df t.ratio p.value
##  Inshore - Mid channel    0.0612 0.0167 1530   3.671  0.0014
##  Inshore - Offshore       0.1176 0.0176 1530   6.668  <.0001
##  Inshore - Oceanic        0.1581 0.0257 1530   6.142  <.0001
##  Mid channel - Offshore   0.0565 0.0193 1530   2.923  0.0184
##  Mid channel - Oceanic    0.0969 0.0269 1530   3.600  0.0019
##  Offshore - Oceanic       0.0404 0.0275 1530   1.468  0.4572
## 
## P value adjustment: tukey method for comparing a family of 4 estimates

Only offshore and oceanic share the same temperature/salinity slopes. All other zones are different among each other

Region and zone

Tep_Sal_Reg<- ggplot(FLK.data) + MyTheme+
  geom_point(aes (Temperature_C, BestSalinity, fill=Sub_region, shape=Zone),
             alpha=0.6, size=0.8)+
  geom_smooth(aes(Temperature_C, BestSalinity, colour=Sub_region),
              linetype=1, method = "lm", se=F)+
  geom_smooth(aes(Temperature_C, BestSalinity),
              linetype=1, method = "lm", colour="black")+
  Zone_shapes4+
  guides(shape="none")+
  scale_y_continuous(#limits = c(1700, 2400),
                     expand = c(0.3, 0.02),
                     name=expression(Salinity))+
  scale_x_continuous(#limits = c(1700, 2400),
                     expand = c(0.02, 0.02),
                     name=expression(paste("Tem")))
Tep_Sal_Reg + facet_grid(~Zone)

  • Tem-Sal: Model II OLS regressions - region and zone
TS_coef_OLS <- FLK.data %>%
                group_by(Sub_region, Zone) %>%
                do({model = lm(BestSalinity~Temperature_C, data=.)  # model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
#TS_coef_OLS

kable(as.data.frame(TS_coef_OLS[,1:9], format = "markdown"), 
      caption = "Table: Salinity vs Temperature linear regressions by region and zone",
      digits = 3)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table: Salinity vs Temperature linear regressions by region and zone
Sub_region Zone term estimate std.error statistic p.value r.squared adj.r.squared
BB Inshore (Intercept) 35.514 0.860 41.318 0.000 0.001 -0.011
BB Inshore Temperature_C 0.011 0.032 0.342 0.733 0.001 -0.011
BB Mid channel (Intercept) 38.118 0.672 56.757 0.000 0.120 0.108
BB Mid channel Temperature_C -0.078 0.025 -3.150 0.002 0.120 0.108
BB Offshore (Intercept) 38.661 0.763 50.646 0.000 0.138 0.127
BB Offshore Temperature_C -0.099 0.028 -3.576 0.001 0.138 0.127
UK Inshore (Intercept) 35.644 0.679 52.498 0.000 0.003 -0.007
UK Inshore Temperature_C 0.014 0.025 0.563 0.575 0.003 -0.007
UK Mid channel (Intercept) 37.575 0.649 57.940 0.000 0.083 0.069
UK Mid channel Temperature_C -0.058 0.024 -2.478 0.016 0.083 0.069
UK Offshore (Intercept) 38.464 0.530 72.571 0.000 0.167 0.159
UK Offshore Temperature_C -0.089 0.019 -4.647 0.000 0.167 0.159
UK Oceanic (Intercept) 40.477 1.211 33.429 0.000 0.300 0.279
UK Oceanic Temperature_C -0.168 0.044 -3.816 0.001 0.300 0.279
MK Inshore (Intercept) 32.925 0.896 36.728 0.000 0.093 0.086
MK Inshore Temperature_C 0.116 0.033 3.541 0.001 0.093 0.086
MK Mid channel (Intercept) 36.017 0.657 54.790 0.000 0.000 -0.008
MK Mid channel Temperature_C 0.000 0.024 0.014 0.989 0.000 -0.008
MK Offshore (Intercept) 37.908 0.565 67.133 0.000 0.087 0.080
MK Offshore Temperature_C -0.071 0.021 -3.455 0.001 0.087 0.080
MK Oceanic (Intercept) 38.702 0.662 58.421 0.000 0.181 0.170
MK Oceanic Temperature_C -0.098 0.024 -4.094 0.000 0.181 0.170
LK Inshore (Intercept) 35.413 0.632 56.002 0.000 0.010 0.002
LK Inshore Temperature_C 0.026 0.024 1.123 0.263 0.010 0.002
LK Mid channel (Intercept) 35.672 0.555 64.285 0.000 0.002 -0.005
LK Mid channel Temperature_C 0.011 0.020 0.545 0.586 0.002 -0.005
LK Offshore (Intercept) 37.380 0.481 77.683 0.000 0.048 0.042
LK Offshore Temperature_C -0.051 0.018 -2.879 0.005 0.048 0.042
LK Oceanic (Intercept) 38.732 0.683 56.708 0.000 0.164 0.154
LK Oceanic Temperature_C -0.100 0.025 -4.030 0.000 0.164 0.154
#write.csv(TS_coef_OLS, "FLK_results/TA_Sal.csv")
  • Are Temp vs Sal slopes different in the regions?
# All data 
T_sal_model<-lm(BestSalinity~Temperature_C * Sub_region * Zone, data=FLK.data)
    anova(T_sal_model)
    #summary(T_sal_model)
    # TA_sal_aov<-aov(T_sal_model)
    # TA_PostH<-TukeyHSD(TA_sal_aov, c("Sub_region", "Zone"), 
    #                    ordered = TRUE)
    # TA_PostH
    
    m.lst <- lstrends(T_sal_model, "Sub_region", var="Temperature_C")
    pairs(m.lst)
##  contrast estimate     SE   df t.ratio p.value
##  BB - UK    nonEst     NA   NA      NA      NA
##  BB - MK    nonEst     NA   NA      NA      NA
##  BB - LK    nonEst     NA   NA      NA      NA
##  UK - MK   -0.0622 0.0228 1508  -2.730  0.0325
##  UK - LK   -0.0470 0.0221 1508  -2.126  0.1454
##  MK - LK    0.0152 0.0189 1508   0.803  0.8528
## 
## Results are averaged over the levels of: Zone 
## P value adjustment: tukey method for comparing a family of 4 estimates
# Inshore data 
T_sal_model_in<-lm(BestSalinity~Temperature_C * Sub_region,
                     data=FLK.data[FLK.data$Zone=="Inshore", ])
    anova(T_sal_model_in)
    summary(T_sal_model_in)
## 
## Call:
## lm(formula = BestSalinity ~ Temperature_C * Sub_region, data = FLK.data[FLK.data$Zone == 
##     "Inshore", ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.3937 -0.4096  0.2131  0.6869  2.5881 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                35.514292   0.986874  35.987   <2e-16 ***
## Temperature_C               0.010927   0.036698   0.298   0.7660    
## Sub_regionUK                0.129329   1.247429   0.104   0.9175    
## Sub_regionMK               -2.589403   1.232995  -2.100   0.0363 *  
## Sub_regionLK               -0.101015   1.196342  -0.084   0.9327    
## Temperature_C:Sub_regionUK  0.003163   0.046247   0.068   0.9455    
## Temperature_C:Sub_regionMK  0.105398   0.045614   2.311   0.0213 *  
## Temperature_C:Sub_regionLK  0.015541   0.044516   0.349   0.7272    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.068 on 437 degrees of freedom
## Multiple R-squared:  0.05328,    Adjusted R-squared:  0.03812 
## F-statistic: 3.514 on 7 and 437 DF,  p-value: 0.00111
    m.lst <- lstrends(T_sal_model_in, "Sub_region", var="Temperature_C") 
    pairs(m.lst)
##  contrast estimate     SE  df t.ratio p.value
##  BB - UK  -0.00316 0.0462 437  -0.068  0.9999
##  BB - MK  -0.10540 0.0456 437  -2.311  0.0972
##  BB - LK  -0.01554 0.0445 437  -0.349  0.9854
##  UK - MK  -0.10224 0.0391 437  -2.617  0.0452
##  UK - LK  -0.01238 0.0378 437  -0.328  0.9878
##  MK - LK   0.08986 0.0370 437   2.429  0.0732
## 
## P value adjustment: tukey method for comparing a family of 4 estimates

Inshore, Upper and middle keys slopes are different from each other

3.1 Temperature impacts on TA and DIC

3.1.1 Temperature and TA: Model II OLS regressions

  • Temperature-TA plots by zone
TA_Tem<- ggplot(FLK.data) + MyTheme+
  geom_point(aes (Temperature_C, TA_umol_kg, fill=Season, shape=Zone),
             alpha=0.7, size=1)+
  geom_smooth(aes(Temperature_C, TA_umol_kg),
              linetype=1, method = "lm", color="black")+
  #Precipitation_fill+
  Season_fill+
  Zone_shapes4+
  guides(shape="none")+
  scale_y_continuous(#limits = c(1700, 2400),
                     expand = c(0.3, 0.02),
                     name=expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  scale_x_continuous(#limits = c(1700, 2400),
                     expand = c(0.02, 0.02),
                     (expression("Temperature"~(degree*C))))
TA_Tem + facet_grid(~Zone)

#TA_Sal+ facet_grid(Zone~Precipitation)
#ggsave(file="FLK_results/TA_Sal.svg", plot=TA_Sal_all, dpi = 300, width=5, height=5)
  • Tem-TA: Model II OLS regressions
TA_coef_OLS <- FLK.data %>%
                group_by(Zone) %>%
                do({model = lm(TA_umol_kg~Temperature_C, data=.)  # model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
#TA_coef_OLS

kable(as.data.frame(TA_coef_OLS[,1:9], format = "markdown"), 
      caption = "Table: TA vs Temperature linear regressions by zone",
      digits = 3)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table: TA vs Temperature linear regressions by zone
Zone term estimate std.error statistic p.value r.squared adj.r.squared sigma
Inshore (Intercept) 2798.372 28.592 97.872 0 0.368 0.367 79.490
Inshore Temperature_C -16.946 1.057 -16.028 0 0.368 0.367 79.490
Mid channel (Intercept) 2634.359 21.862 120.501 0 0.275 0.274 47.919
Mid channel Temperature_C -9.911 0.800 -12.389 0 0.275 0.274 47.919
Offshore (Intercept) 2502.306 12.432 201.274 0 0.175 0.174 24.776
Offshore Temperature_C -4.578 0.453 -10.106 0 0.175 0.174 24.776
Oceanic (Intercept) 2421.972 10.730 225.711 0 0.068 0.064 12.937
Oceanic Temperature_C -1.476 0.390 -3.780 0 0.068 0.064 12.937
#write.csv(TA_coef_OLS, "FLK_results/TA_Sal.csv")
  • Are TA vs Temperature slopes different in each zone?
# All data 
TA_tem_model<-lm(TA_umol_kg~Temperature_C * Sub_region * Zone, data=FLK.data)
    anova(TA_tem_model)
    #summary(TA_tem_model)
    # TA_sal_aov<-aov(TA_tem_model)
    # TA_PostH<-TukeyHSD(TA_sal_aov, c( "Zone"), 
    #                    ordered = TRUE)
    # TA_PostH
    
    m.lst <- lstrends(TA_tem_model, "Zone", var="Temperature_C")
    pairs(m.lst)
##  contrast               estimate   SE   df t.ratio p.value
##  Inshore - Mid channel     -8.00 1.08 1498  -7.402  <.0001
##  Inshore - Offshore       -12.27 1.11 1498 -11.030  <.0001
##  Inshore - Oceanic        nonEst   NA   NA      NA      NA
##  Mid channel - Offshore    -4.27 1.25 1498  -3.421  0.0036
##  Mid channel - Oceanic    nonEst   NA   NA      NA      NA
##  Offshore - Oceanic       nonEst   NA   NA      NA      NA
## 
## Results are averaged over the levels of: Sub_region 
## P value adjustment: tukey method for comparing a family of 4 estimates
  • Temperature-TA plots by region and zone
TA_Temp_Reg<- ggplot(FLK.data) + MyTheme+
  geom_point(aes (Temperature_C, TA_umol_kg, fill=Sub_region, shape=Zone),
             alpha=0.6, size=0.8)+
  geom_smooth(aes(Temperature_C, TA_umol_kg, colour=Sub_region),
              linetype=1, method = "lm", se=F)+
  geom_smooth(aes(Temperature_C, TA_umol_kg),
              linetype=1, method = "lm", colour="black")+
  Zone_shapes4+
  guides(shape="none")+
  scale_y_continuous(#limits = c(1700, 2400),
                     expand = c(0.3, 0.02),
                     name=expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  scale_x_continuous(#limits = c(1700, 2400),
                     expand = c(0.02, 0.02),
                     (expression("Temperature"~(degree*C))))
TA_Temp_Reg + facet_grid(~Zone)

#ggsave(file="FLK_results/TA_Sal.svg", plot=TA_Sal_all, dpi = 300, width=5, height=5)
  • Temperature-TA: Model II OLS regressions
TA_coef_OLS <- FLK.data %>%
                group_by(Sub_region, Zone) %>%
                do({model = lm(TA_umol_kg~Temperature_C, data=.)  # model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
#TA_coef_OLS

kable(as.data.frame(TA_coef_OLS[,1:9], format = "markdown"), 
      caption = "Table: TA vs Temperature linear regressions by region and zone",
      digits = 3)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table: TA vs Temperature linear regressions by region and zone
Sub_region Zone term estimate std.error statistic p.value r.squared adj.r.squared
BB Inshore (Intercept) 2698.279 50.940 52.970 0.000 0.340 0.332
BB Inshore Temperature_C -12.230 1.894 -6.456 0.000 0.340 0.332
BB Mid channel (Intercept) 2511.829 24.681 101.771 0.000 0.289 0.279
BB Mid channel Temperature_C -4.933 0.906 -5.446 0.000 0.289 0.279
BB Offshore (Intercept) 2461.272 19.695 124.971 0.000 0.177 0.166
BB Offshore Temperature_C -2.973 0.718 -4.143 0.000 0.177 0.166
UK Inshore (Intercept) 2721.444 41.735 65.208 0.000 0.401 0.395
UK Inshore Temperature_C -12.710 1.539 -8.260 0.000 0.401 0.395
UK Mid channel (Intercept) 2510.825 20.678 121.424 0.000 0.370 0.361
UK Mid channel Temperature_C -4.752 0.752 -6.321 0.000 0.370 0.361
UK Offshore (Intercept) 2467.795 14.519 169.975 0.000 0.259 0.252
UK Offshore Temperature_C -3.197 0.525 -6.086 0.000 0.259 0.252
UK Oceanic (Intercept) 2448.227 25.938 94.388 0.000 0.170 0.145
UK Oceanic Temperature_C -2.454 0.944 -2.599 0.014 0.170 0.145
MK Inshore (Intercept) 2981.112 54.341 54.860 0.000 0.536 0.532
MK Inshore Temperature_C -23.534 1.991 -11.821 0.000 0.536 0.532
MK Mid channel (Intercept) 2709.405 42.140 64.296 0.000 0.360 0.355
MK Mid channel Temperature_C -12.788 1.536 -8.326 0.000 0.360 0.355
MK Offshore (Intercept) 2518.793 24.287 103.712 0.000 0.225 0.219
MK Offshore Temperature_C -5.322 0.887 -6.004 0.000 0.225 0.219
MK Oceanic (Intercept) 2404.770 18.117 132.737 0.000 0.021 0.008
MK Oceanic Temperature_C -0.841 0.656 -1.282 0.204 0.021 0.008
LK Inshore (Intercept) 2770.671 49.923 55.499 0.000 0.410 0.406
LK Inshore Temperature_C -17.752 1.860 -9.543 0.000 0.410 0.406
LK Mid channel (Intercept) 2671.318 42.396 63.009 0.000 0.298 0.292
LK Mid channel Temperature_C -11.755 1.560 -7.537 0.000 0.298 0.292
LK Offshore (Intercept) 2530.750 27.022 93.654 0.000 0.166 0.161
LK Offshore Temperature_C -5.653 0.988 -5.721 0.000 0.166 0.161
LK Oceanic (Intercept) 2425.155 15.606 155.401 0.000 0.086 0.075
LK Oceanic Temperature_C -1.593 0.570 -2.796 0.006 0.086 0.075
#write.csv(TA_coef_OLS, "FLK_results/TA_Sal.csv")
  • Are TA vs Temperature slopes different by region?
# All data 
TA_tem_model<-lm(TA_umol_kg~Temperature_C * Sub_region * Zone, data=FLK.data)
    anova(TA_tem_model)
    #summary(TA_tem_model)
    # TA_sal_aov<-aov(TA_tem_model)
    # TA_PostH<-TukeyHSD(TA_sal_aov, c("Sub_region", "Zone"), 
    #                    ordered = TRUE)
    # TA_PostH
    
    m.lst <- lstrends(TA_tem_model, "Sub_region", var="Temperature_C")
    pairs(m.lst)
##  contrast estimate   SE   df t.ratio p.value
##  BB - UK    nonEst   NA   NA      NA      NA
##  BB - MK    nonEst   NA   NA      NA      NA
##  BB - LK    nonEst   NA   NA      NA      NA
##  UK - MK      4.84 1.38 1498   3.514  0.0026
##  UK - LK      3.41 1.34 1498   2.549  0.0532
##  MK - LK     -1.43 1.14 1498  -1.253  0.5929
## 
## Results are averaged over the levels of: Zone 
## P value adjustment: tukey method for comparing a family of 4 estimates
# Inshore data 
TA_tem_model_in<-lm(TA_umol_kg~Temperature_C * Sub_region,
                     data=FLK.data[FLK.data$Zone=="Inshore", ])
    anova(TA_tem_model_in)
    summary(TA_tem_model_in)
## 
## Call:
## lm(formula = TA_umol_kg ~ Temperature_C * Sub_region, data = FLK.data[FLK.data$Zone == 
##     "Inshore", ])
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -280.776  -35.706    3.262   43.723  165.652 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                2698.2787    65.0050  41.509  < 2e-16 ***
## Temperature_C               -12.2296     2.4173  -5.059 6.22e-07 ***
## Sub_regionUK                 23.1650    82.1900   0.282 0.778195    
## Sub_regionMK                282.8329    81.2411   3.481 0.000549 ***
## Sub_regionLK                 72.3922    78.8025   0.919 0.358786    
## Temperature_C:Sub_regionUK   -0.4805     3.0466  -0.158 0.874765    
## Temperature_C:Sub_regionMK  -11.3043     3.0050  -3.762 0.000192 ***
## Temperature_C:Sub_regionLK   -5.5220     2.9322  -1.883 0.060339 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 70.35 on 435 degrees of freedom
##   (2 observations deleted due to missingness)
## Multiple R-squared:  0.5117, Adjusted R-squared:  0.5039 
## F-statistic: 65.13 on 7 and 435 DF,  p-value: < 2.2e-16
    m.lst <- lstrends(TA_tem_model_in, "Sub_region", var="Temperature_C") 
    pairs(m.lst)
##  contrast estimate   SE  df t.ratio p.value
##  BB - UK      0.48 3.05 435   0.158  0.9986
##  BB - MK     11.30 3.01 435   3.762  0.0011
##  BB - LK      5.52 2.93 435   1.883  0.2368
##  UK - MK     10.82 2.57 435   4.205  0.0002
##  UK - LK      5.04 2.49 435   2.026  0.1800
##  MK - LK     -5.78 2.44 435  -2.372  0.0840
## 
## P value adjustment: tukey method for comparing a family of 4 estimates

3.1.2 Temperature and DIC: Model II OLS regressions

  • Temperature-DIC plots by zone
DIC_Tem<- ggplot(FLK.data) + MyTheme+
  geom_point(aes (Temperature_C, DIC_umol_kg, fill=Season, shape=Zone),
             alpha=0.7, size=1)+
  geom_smooth(aes(Temperature_C, DIC_umol_kg),
              linetype=1, method = "lm", color="black")+
  #Precipitation_fill+
  Season_fill+
  Zone_shapes4+
  guides(shape="none")+
  scale_y_continuous(#limits = c(1700, 2400),
                     expand = c(0.3, 0.02),
                     name=expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
  scale_x_continuous(#limits = c(1700, 2400),
                     expand = c(0.02, 0.02),
                     (expression("Temperature"~(degree*C))))
DIC_Tem + facet_grid(~Zone)

#ggsave(file="FLK_results/DIC_Sal.svg", plot=DIC_Sal_all, dpi = 300, width=5, height=5)
  • Tem-DIC: Model II OLS regressions
DIC_coef_OLS <- FLK.data %>%
                group_by(Zone) %>%
                do({model = lm(DIC_umol_kg~Temperature_C, data=.)  # model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
#DIC_coef_OLS

kable(as.data.frame(DIC_coef_OLS[,1:9], format = "markdown"), 
      caption = "Table: DIC vs Temperature linear regressions by zone",
      digits = 3)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table: DIC vs Temperature linear regressions by zone
Zone term estimate std.error statistic p.value r.squared adj.r.squared sigma
Inshore (Intercept) 2498.372 33.146 75.374 0 0.322 0.320 91.764
Inshore Temperature_C -17.752 1.227 -14.466 0 0.322 0.320 91.764
Mid channel (Intercept) 2337.591 23.609 99.013 0 0.289 0.287 51.566
Mid channel Temperature_C -11.060 0.865 -12.792 0 0.289 0.287 51.566
Offshore (Intercept) 2198.529 13.777 159.585 0 0.202 0.200 27.362
Offshore Temperature_C -5.543 0.502 -11.030 0 0.202 0.200 27.362
Oceanic (Intercept) 2125.476 18.299 116.150 0 0.087 0.082 21.857
Oceanic Temperature_C -2.864 0.666 -4.298 0 0.087 0.082 21.857
#write.csv(DIC_coef_OLS, "FLK_results/DIC_Sal.csv")
  • Are DIC vs Temperature slopes different in each zone?
# All data 
DIC_tem_model<-lm(DIC_umol_kg~Temperature_C * Sub_region * Zone, data=FLK.data)
    anova(DIC_tem_model)
    #summary(DIC_tem_model)
    # DIC_sal_aov<-aov(DIC_tem_model)
    # DIC_PostH<-TukeyHSD(DIC_sal_aov, c( "Zone"), 
    #                    ordered = TRUE)
    # DIC_PostH
    #
    m.lst <- lstrends(DIC_tem_model, "Zone", var="Temperature_C")
    pairs(m.lst)
##  contrast               estimate   SE   df t.ratio p.value
##  Inshore - Mid channel     -7.84 1.30 1498  -6.009  <.0001
##  Inshore - Offshore       -12.16 1.34 1498  -9.050  <.0001
##  Inshore - Oceanic        nonEst   NA   NA      NA      NA
##  Mid channel - Offshore    -4.32 1.51 1498  -2.866  0.0219
##  Mid channel - Oceanic    nonEst   NA   NA      NA      NA
##  Offshore - Oceanic       nonEst   NA   NA      NA      NA
## 
## Results are averaged over the levels of: Sub_region 
## P value adjustment: tukey method for comparing a family of 4 estimates
  • Temperature-DIC plots by region and zone
DIC_Temp_Reg<- ggplot(FLK.data) + MyTheme+
  geom_point(aes (Temperature_C, DIC_umol_kg, fill=Sub_region, shape=Zone),
             alpha=0.6, size=0.8)+
  geom_smooth(aes(Temperature_C, DIC_umol_kg, colour=Sub_region),
              linetype=1, method = "lm", se=F)+
  geom_smooth(aes(Temperature_C, DIC_umol_kg),
              linetype=1, method = "lm", colour="black")+
  guides(shape="none")+
  Zone_shapes4+
  scale_y_continuous(#limits = c(1700, 2400),
                     expand = c(0.3, 0.02),
                     name=expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
  scale_x_continuous(#limits = c(1700, 2400),
                     expand = c(0.02, 0.02),
                     (expression("Temperature"~(degree*C))))
DIC_Temp_Reg + facet_grid(~Zone)

#ggsave(file="FLK_results/DIC_Sal.svg", plot=DIC_Sal_all, dpi = 300, width=5, height=5)
  • Temperature-DIC: Model II OLS regressions by region and zone
DIC_coef_OLS <- FLK.data %>%
                group_by(Sub_region, Zone) %>%
                do({model = lm(DIC_umol_kg~Temperature_C, data=.)  # model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
#DIC_coef_OLS

kable(as.data.frame(DIC_coef_OLS[,1:9], format = "markdown"), 
      caption = "Table: DIC vs Temperature linear regressions by region and zone",
      digits = 3)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table: DIC vs Temperature linear regressions by region and zone
Sub_region Zone term estimate std.error statistic p.value r.squared adj.r.squared
BB Inshore (Intercept) 2380.935 75.498 31.536 0.000 0.190 0.180
BB Inshore Temperature_C -12.239 2.808 -4.359 0.000 0.190 0.180
BB Mid channel (Intercept) 2176.197 41.747 52.128 0.000 0.108 0.096
BB Mid channel Temperature_C -4.561 1.532 -2.977 0.004 0.108 0.096
BB Offshore (Intercept) 2112.423 25.551 82.675 0.000 0.069 0.058
BB Offshore Temperature_C -2.269 0.931 -2.438 0.017 0.069 0.058
UK Inshore (Intercept) 2439.277 70.739 34.483 0.000 0.237 0.230
UK Inshore Temperature_C -14.777 2.609 -5.664 0.000 0.237 0.230
UK Mid channel (Intercept) 2196.767 40.597 54.112 0.000 0.169 0.157
UK Mid channel Temperature_C -5.498 1.476 -3.725 0.000 0.169 0.157
UK Offshore (Intercept) 2168.106 21.885 99.068 0.000 0.221 0.214
UK Offshore Temperature_C -4.368 0.792 -5.516 0.000 0.221 0.214
UK Oceanic (Intercept) 2126.929 46.942 45.310 0.000 0.087 0.060
UK Oceanic Temperature_C -3.066 1.708 -1.795 0.082 0.087 0.060
MK Inshore (Intercept) 2665.966 61.481 43.362 0.000 0.486 0.482
MK Inshore Temperature_C -24.207 2.253 -10.743 0.000 0.486 0.482
MK Mid channel (Intercept) 2400.620 44.735 53.664 0.000 0.363 0.357
MK Mid channel Temperature_C -13.697 1.631 -8.399 0.000 0.363 0.357
MK Offshore (Intercept) 2228.318 28.698 77.647 0.000 0.258 0.252
MK Offshore Temperature_C -6.905 1.048 -6.592 0.000 0.258 0.252
MK Oceanic (Intercept) 2121.151 30.420 69.729 0.000 0.072 0.060
MK Oceanic Temperature_C -2.673 1.102 -2.426 0.018 0.072 0.060
LK Inshore (Intercept) 2465.218 52.591 46.875 0.000 0.383 0.378
LK Inshore Temperature_C -17.589 1.966 -8.945 0.000 0.383 0.378
LK Mid channel (Intercept) 2402.872 42.298 56.808 0.000 0.369 0.364
LK Mid channel Temperature_C -13.703 1.560 -8.785 0.000 0.369 0.364
LK Offshore (Intercept) 2231.180 26.161 85.286 0.000 0.227 0.223
LK Offshore Temperature_C -6.644 0.959 -6.926 0.000 0.227 0.223
LK Oceanic (Intercept) 2128.263 26.221 81.167 0.000 0.103 0.092
LK Oceanic Temperature_C -2.934 0.960 -3.055 0.003 0.103 0.092
#write.csv(DIC_coef_OLS, "FLK_results/DIC_Sal.csv")
  • Are DIC vs Temperature slopes different by region?
# All data 
DIC_tem_model<-lm(DIC_umol_kg~Temperature_C * Sub_region * Zone, data=FLK.data)
    anova(DIC_tem_model)
    #summary(DIC_tem_model)
    # DIC_sal_aov<-aov(DIC_tem_model)
    # DIC_PostH<-TukeyHSD(DIC_sal_aov, c("Sub_region", "Zone"), 
    #                    ordered = TRUE)
    # DIC_PostH
    
    m.lst <- lstrends(DIC_tem_model, "Sub_region", var="Temperature_C")
    pairs(m.lst)
##  contrast estimate   SE   df t.ratio p.value
##  BB - UK    nonEst   NA   NA      NA      NA
##  BB - MK    nonEst   NA   NA      NA      NA
##  BB - LK    nonEst   NA   NA      NA      NA
##  UK - MK      4.94 1.66 1498   2.980  0.0155
##  UK - LK      3.29 1.62 1498   2.029  0.1779
##  MK - LK     -1.65 1.39 1498  -1.189  0.6337
## 
## Results are averaged over the levels of: Zone 
## P value adjustment: tukey method for comparing a family of 4 estimates
# Inshore data 
DIC_tem_model_in<-lm(DIC_umol_kg~Temperature_C * Sub_region,
                     data=FLK.data[FLK.data$Zone=="Inshore", ])
    anova(DIC_tem_model_in)
    summary(DIC_tem_model_in)
## 
## Call:
## lm(formula = DIC_umol_kg ~ Temperature_C * Sub_region, data = FLK.data[FLK.data$Zone == 
##     "Inshore", ])
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -276.879  -44.573    8.359   57.962  228.870 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                2380.935     81.401  29.249  < 2e-16 ***
## Temperature_C               -12.239      3.027  -4.043 6.23e-05 ***
## Sub_regionUK                 58.342    102.893   0.567  0.57100    
## Sub_regionMK                285.032    101.702   2.803  0.00530 ** 
## Sub_regionLK                 84.283     99.180   0.850  0.39590    
## Temperature_C:Sub_regionUK   -2.538      3.815  -0.665  0.50617    
## Temperature_C:Sub_regionMK  -11.968      3.762  -3.181  0.00157 ** 
## Temperature_C:Sub_regionLK   -5.350      3.695  -1.448  0.14836    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 88.1 on 435 degrees of freedom
##   (2 observations deleted due to missingness)
## Multiple R-squared:  0.3834, Adjusted R-squared:  0.3735 
## F-statistic: 38.64 on 7 and 435 DF,  p-value: < 2.2e-16
    m.lst <- lstrends(DIC_tem_model_in, "Sub_region", var="Temperature_C") 
    pairs(m.lst)
##  contrast estimate   SE  df t.ratio p.value
##  BB - UK      2.54 3.81 435   0.665  0.9101
##  BB - MK     11.97 3.76 435   3.181  0.0085
##  BB - LK      5.35 3.69 435   1.448  0.4702
##  UK - MK      9.43 3.22 435   2.927  0.0188
##  UK - LK      2.81 3.14 435   0.895  0.8077
##  MK - LK     -6.62 3.08 435  -2.149  0.1394
## 
## P value adjustment: tukey method for comparing a family of 4 estimates

3.1.3 TA/DIC Temperature

  • TA/DIC vs Temperature plots by zone
FLK.data$TA_DIC<-FLK.data$TA_umol_kg/FLK.data$DIC_umol_kg

TA_DIC_Sal<- ggplot(FLK.data) + MyTheme+
  geom_point(aes (Temperature_C, TA_DIC, fill=Season, shape=Zone),
             alpha=0.6, size=.8)+
  # geom_smooth(aes(Temperature_C, TA_DIC, colour=Sub_region),
  #             linetype=1, method = "lm", se=F)+
    geom_smooth(aes(Temperature_C, TA_DIC),
               linetype=1, method = "lm", colour="black")+
  Zone_shapes4+
  Season_fill+
  guides(shape="none")+
  scale_y_continuous(#limits = c(1700, 2400),
                     expand = c(0.02, 0.02),
                     name=expression(paste("TA/DIC")))+
  scale_x_continuous(#limits = c(1700, 2400),
                     expand = c(0.02, 0.02),
                     (expression("Temperature"~(degree*C))))
TA_DIC_Sal + facet_grid(~Zone)

  • TA/DIC vs Temperature: Model II OLS regressions by zone
##TA/DIC vs sal by zone
TA_DIC_Sal_Z <- FLK.data %>%
                  group_by(Zone) %>%
                  do({model = lm(TA_DIC~Temperature_C, data=.)
                  # create model
                  data.frame(tidy(model), # get coefficient info
                  glance(model))})        # get model info
#TA_DIC_Sal_Z
  
kable(as.data.frame(TA_DIC_Sal_Z[,1:8], format = "markdown"), 
      caption = "Table: TA/DIC vs Tem by zone",
      digits = 3)%>% 
      kable_styling(bootstrap_options = c("striped", "condensed", 
                                      full_width = F), font_size = 11)
Table: TA/DIC vs Tem by zone
Zone term estimate std.error statistic p.value r.squared adj.r.squared
Inshore (Intercept) 1.110 0.011 96.840 0.000 0.042 0.040
Inshore Temperature_C 0.002 0.000 4.396 0.000 0.042 0.040
Mid channel (Intercept) 1.124 0.008 138.167 0.000 0.050 0.047
Mid channel Temperature_C 0.001 0.000 4.577 0.000 0.050 0.047
Offshore (Intercept) 1.137 0.005 228.443 0.000 0.047 0.045
Offshore Temperature_C 0.001 0.000 4.858 0.000 0.047 0.045
Oceanic (Intercept) 1.139 0.008 149.988 0.000 0.049 0.045
Oceanic Temperature_C 0.001 0.000 3.168 0.002 0.049 0.045
#write.csv(TA_DIC_Sal_Z, "FLK_results/TA_DIC_Z.csv")
    • TA/DIC vs Temperature: Model II OLS regressions by region and zone
##TA/DIC vs sal by regions and zone
TADIC_Sal <- FLK.data %>%
                  group_by(Sub_region, Zone) %>%
                  do({model = lm(TA_DIC~Temperature_C, data=.)
                  # create model
                  data.frame(tidy(model), # get coefficient info
                  glance(model))})        # get model info
#TADIC_Sal
  
kable(as.data.frame(TADIC_Sal[,1:8], format = "markdown"), 
      caption = "Table: TA/DIC vs Tem by zone and region",
      digits = 3)%>% 
      kable_styling(bootstrap_options = c("striped", "condensed", 
                                      full_width = F), font_size = 11)
Table: TA/DIC vs Tem by zone and region
Sub_region Zone term estimate std.error statistic p.value r.squared
BB Inshore (Intercept) 1.130 0.026 42.907 0.000 0.012
BB Inshore Temperature_C 0.001 0.001 0.995 0.323 0.012
BB Mid channel (Intercept) 1.154 0.017 66.198 0.000 0.001
BB Mid channel Temperature_C 0.000 0.001 0.275 0.784 0.001
BB Offshore (Intercept) 1.165 0.012 100.774 0.000 0.002
BB Offshore Temperature_C 0.000 0.000 -0.377 0.707 0.002
UK Inshore (Intercept) 1.112 0.026 42.023 0.000 0.042
UK Inshore Temperature_C 0.002 0.001 2.102 0.038 0.042
UK Mid channel (Intercept) 1.143 0.021 55.312 0.000 0.015
UK Mid channel Temperature_C 0.001 0.001 1.012 0.315 0.015
UK Offshore (Intercept) 1.136 0.010 112.508 0.000 0.059
UK Offshore Temperature_C 0.001 0.000 2.569 0.012 0.059
UK Oceanic (Intercept) 1.154 0.019 61.144 0.000 0.009
UK Oceanic Temperature_C 0.000 0.001 0.557 0.582 0.009
MK Inshore (Intercept) 1.106 0.022 50.022 0.000 0.060
MK Inshore Temperature_C 0.002 0.001 2.791 0.006 0.060
MK Mid channel (Intercept) 1.123 0.015 72.798 0.000 0.057
MK Mid channel Temperature_C 0.002 0.001 2.716 0.008 0.057
MK Offshore (Intercept) 1.127 0.010 113.634 0.000 0.098
MK Offshore Temperature_C 0.001 0.000 3.675 0.000 0.098
MK Oceanic (Intercept) 1.133 0.012 95.040 0.000 0.084
MK Oceanic Temperature_C 0.001 0.000 2.616 0.011 0.084
LK Inshore (Intercept) 1.113 0.017 64.330 0.000 0.038
LK Inshore Temperature_C 0.001 0.001 2.247 0.026 0.038
LK Mid channel (Intercept) 1.110 0.013 85.385 0.000 0.095
LK Mid channel Temperature_C 0.002 0.000 3.728 0.000 0.095
LK Offshore (Intercept) 1.135 0.008 135.664 0.000 0.050
LK Offshore Temperature_C 0.001 0.000 2.905 0.004 0.050
LK Oceanic (Intercept) 1.139 0.012 97.043 0.000 0.047
LK Oceanic Temperature_C 0.001 0.000 2.000 0.049 0.047
#write.csv(TADIC_Sal, "FLK_results/TA_DIC_all.csv")
  • Are the TA/DIC slopes different?
TA_DIA_sal_model<-lm(TA_DIC~Temperature_C * Sub_region * Zone, data=FLK.data)
    anova(TA_DIA_sal_model)
    #summary(TA_DIA_sal_model)
    # DIC_sal_aov<-aov(TA_DIA_sal_model)
    # TADIC_PostH<-TukeyHSD(DIC_sal_aov, c("Sub_region", "Zone"), ordered = TRUE)
    # TADIC_PostH
    
    m.lst <- lstrends(TA_DIA_sal_model, "Sub_region", var="Temperature_C") 
    pairs(m.lst)
##  contrast  estimate       SE   df t.ratio p.value
##  BB - UK     nonEst       NA   NA      NA      NA
##  BB - MK     nonEst       NA   NA      NA      NA
##  BB - LK     nonEst       NA   NA      NA      NA
##  UK - MK  -0.000529 0.000592 1489  -0.894  0.8082
##  UK - LK  -0.000215 0.000578 1489  -0.371  0.9826
##  MK - LK   0.000314 0.000496 1489   0.634  0.9212
## 
## Results are averaged over the levels of: Zone 
## P value adjustment: tukey method for comparing a family of 4 estimates
TA_DIA_sal_model_in<-lm(TA_DIC~Temperature_C * Sub_region, 
                     data=FLK.data[FLK.data$Zone=="Inshore",])
    anova(TA_DIA_sal_model_in)
    summary(TA_DIA_sal_model_in)
## 
## Call:
## lm(formula = TA_DIC ~ Temperature_C * Sub_region, data = FLK.data[FLK.data$Zone == 
##     "Inshore", ])
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.069197 -0.022212 -0.002683  0.018660  0.087853 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 1.1296111  0.0288495  39.155   <2e-16 ***
## Temperature_C               0.0009737  0.0010728   0.908    0.365    
## Sub_regionUK               -0.0176889  0.0364763  -0.485    0.628    
## Sub_regionMK               -0.0240068  0.0360551  -0.666    0.506    
## Sub_regionLK               -0.0162474  0.0351504  -0.462    0.644    
## Temperature_C:Sub_regionUK  0.0010771  0.0013521   0.797    0.426    
## Temperature_C:Sub_regionMK  0.0012866  0.0013337   0.965    0.335    
## Temperature_C:Sub_regionLK  0.0004805  0.0013094   0.367    0.714    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.03122 on 433 degrees of freedom
##   (4 observations deleted due to missingness)
## Multiple R-squared:  0.08532,    Adjusted R-squared:  0.07053 
## F-statistic:  5.77 on 7 and 433 DF,  p-value: 2.1e-06
    m.lst <- lstrends(TA_DIA_sal_model_in, "Sub_region", var="Temperature_C") 
    pairs(m.lst)
##  contrast  estimate      SE  df t.ratio p.value
##  BB - UK  -0.001077 0.00135 433  -0.797  0.8560
##  BB - MK  -0.001287 0.00133 433  -0.965  0.7696
##  BB - LK  -0.000480 0.00131 433  -0.367  0.9831
##  UK - MK  -0.000210 0.00114 433  -0.183  0.9978
##  UK - LK   0.000597 0.00111 433   0.536  0.9504
##  MK - LK   0.000806 0.00109 433   0.738  0.8815
## 
## P value adjustment: tukey method for comparing a family of 4 estimates

3.2 Salinity impacts on TA and DIC

  • Uses salinity Bottle first, if not available, uses salinity from CTD
#MeanSalinity<-mean(FLK.data[FLK.data$Zone=="Oceanic",]$BestSalinity)
MeanSalinity<-mean(FLK.data$BestSalinity)
sdSalinity<-sd(FLK.data$BestSalinity)

Sal<-paste("Mean salinity = ", round(MeanSalinity, digits=3),
           "(", round(sdSalinity, digits=3), "sd)")
Sal
## [1] "Mean salinity =  35.998 ( 0.796 sd)"

3.2.1 Salinity TA: Model II OLS regressions

  • Salinity-TA plots by zone
TA_Sal<- ggplot(FLK.data) + MyTheme+
  geom_point(aes (BestSalinity, TA_umol_kg, fill=Season, shape=Zone),
             alpha=0.7, size=1)+
  geom_smooth(aes(BestSalinity, TA_umol_kg),
              linetype=1, method = "lm", color="black")+
  #Precipitation_fill+
  Season_fill+
  Zone_shapes4+
  guides(shape="none")+
  scale_y_continuous(#limits = c(1700, 2400),
                     expand = c(0.3, 0.02),
                     name=expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  scale_x_continuous(#limits = c(1700, 2400),
                     expand = c(0.02, 0.02),
                     name=expression(paste("Salinity")))
TA_Sal + facet_grid(~Zone)

#TA_Sal+ facet_grid(Zone~Precipitation)
#ggsave(file="FLK_results/TA_Sal.svg", plot=TA_Sal_all, dpi = 300, width=5, height=5)
  • Salinity-TA: Model II OLS regressions by zone
TA_coef_OLS <- FLK.data %>%
                group_by(Zone) %>%
                do({model = lm(TA_umol_kg~BestSalinity, data=.)  # model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
#TA_coef_OLS

kable(as.data.frame(TA_coef_OLS[,1:9], format = "markdown"), 
      caption = "Table: TA vs salinity linear regressions by region and zone",
      digits = 3)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table: TA vs salinity linear regressions by region and zone
Zone term estimate std.error statistic p.value r.squared adj.r.squared sigma
Inshore (Intercept) 3044.292 156.999 19.391 0.000 0.043 0.041 97.814
Inshore BestSalinity -19.429 4.354 -4.462 0.000 0.043 0.041 97.814
Mid channel (Intercept) 2012.916 142.211 14.154 0.000 0.015 0.013 55.868
Mid channel BestSalinity 9.782 3.949 2.477 0.014 0.015 0.013 55.868
Offshore (Intercept) 2034.277 74.934 27.148 0.000 0.042 0.040 26.709
Offshore BestSalinity 9.529 2.082 4.577 0.000 0.042 0.040 26.709
Oceanic (Intercept) 2081.902 53.880 38.640 0.000 0.137 0.133 12.451
Oceanic BestSalinity 8.328 1.497 5.562 0.000 0.137 0.133 12.451
#write.csv(TA_coef_OLS, "FLK_results/TA_Sal.csv")
  • Salinity-TA plots by zone and region
TA_Sal_Reg<- ggplot(FLK.data) + MyTheme+
  geom_point(aes (BestSalinity, TA_umol_kg, fill=Sub_region, shape=Zone),
             alpha=0.6, size=0.8)+
  geom_smooth(aes(BestSalinity, TA_umol_kg, colour=Sub_region),
              linetype=1, method = "lm", se=F)+
  geom_smooth(aes(BestSalinity, TA_umol_kg),
              linetype=1, method = "lm", colour="black")+
  Zone_shapes4+
  guides(shape="none")+
  scale_y_continuous(#limits = c(1700, 2400),
                     expand = c(0.3, 0.02),
                     name=expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  scale_x_continuous(#limits = c(1700, 2400),
                     expand = c(0.02, 0.02),
                     name=expression(paste("Salinity")))
TA_Sal_Reg + facet_grid(~Zone)

  • Salinity-TA: Model II OLS regressions by zone and region
TA_coef_OLS <- FLK.data %>%
                group_by(Sub_region, Zone) %>%
                do({model = lm(TA_umol_kg~BestSalinity, data=.)  # model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
#TA_coef_OLS

kable(as.data.frame(TA_coef_OLS[,1:9], format = "markdown"), 
      caption = "Table: TA vs salinity linear regressions by region and zone",
      digits = 3)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table: TA vs salinity linear regressions by region and zone
Sub_region Zone term estimate std.error statistic p.value r.squared adj.r.squared
BB Inshore (Intercept) 3405.556 266.323 12.787 0.000 0.157 0.147
BB Inshore BestSalinity -28.873 7.435 -3.883 0.000 0.157 0.147
BB Mid channel (Intercept) 2105.193 169.387 12.428 0.000 0.034 0.021
BB Mid channel BestSalinity 7.575 4.703 1.611 0.112 0.034 0.021
BB Offshore (Intercept) 2378.141 106.108 22.412 0.000 0.000 -0.012
BB Offshore BestSalinity 0.051 2.952 0.017 0.986 0.000 -0.012
UK Inshore (Intercept) 3023.622 284.676 10.621 0.000 0.048 0.038
UK Inshore BestSalinity -17.856 7.895 -2.262 0.026 0.048 0.038
UK Mid channel (Intercept) 1925.506 158.547 12.145 0.000 0.108 0.095
UK Mid channel BestSalinity 12.657 4.406 2.872 0.005 0.108 0.095
UK Offshore (Intercept) 2033.770 97.680 20.821 0.000 0.106 0.097
UK Offshore BestSalinity 9.607 2.712 3.543 0.001 0.106 0.097
UK Oceanic (Intercept) 2004.389 104.271 19.223 0.000 0.283 0.262
UK Oceanic BestSalinity 10.494 2.904 3.613 0.001 0.283 0.262
MK Inshore (Intercept) 3140.706 278.048 11.296 0.000 0.064 0.056
MK Inshore BestSalinity -22.061 7.696 -2.867 0.005 0.064 0.056
MK Mid channel (Intercept) 2006.183 269.590 7.442 0.000 0.014 0.006
MK Mid channel BestSalinity 9.836 7.477 1.316 0.191 0.014 0.006
MK Offshore (Intercept) 2018.184 150.577 13.403 0.000 0.043 0.035
MK Offshore BestSalinity 9.879 4.185 2.361 0.020 0.043 0.035
MK Oceanic (Intercept) 2121.707 103.310 20.537 0.000 0.078 0.066
MK Oceanic BestSalinity 7.217 2.868 2.516 0.014 0.078 0.066
LK Inshore (Intercept) 2468.931 322.588 7.654 0.000 0.002 -0.005
LK Inshore BestSalinity -4.713 8.928 -0.528 0.599 0.002 -0.005
LK Mid channel (Intercept) 2011.903 281.510 7.147 0.000 0.011 0.004
LK Mid channel BestSalinity 9.508 7.824 1.215 0.226 0.011 0.004
LK Offshore (Intercept) 1850.161 163.024 11.349 0.000 0.060 0.054
LK Offshore BestSalinity 14.631 4.529 3.231 0.001 0.060 0.054
LK Oceanic (Intercept) 2103.902 80.792 26.041 0.000 0.125 0.114
LK Oceanic BestSalinity 7.718 2.245 3.439 0.001 0.125 0.114
#write.csv(TA_coef_OLS, "FLK_results/TA_Sal.csv")
  • Are TA vs Sal slopes different?
# All data 
TA_sal_model<-lm(TA_umol_kg~BestSalinity * Sub_region * Zone, data=FLK.data)
    anova(TA_sal_model)
    #summary(TA_sal_model)
    # TA_sal_aov<-aov(TA_sal_model)
    # TA_PostH<-TukeyHSD(TA_sal_aov, c("Sub_region", "Zone"), 
    #                    ordered = TRUE)
    # TA_PostH
    
    m.lst <- lstrends(TA_sal_model, "Sub_region", var="BestSalinity")
    pairs(m.lst)
##  contrast estimate   SE   df t.ratio p.value
##  BB - UK    nonEst   NA   NA      NA      NA
##  BB - MK    nonEst   NA   NA      NA      NA
##  BB - LK    nonEst   NA   NA      NA      NA
##  UK - MK      2.51 7.10 1498   0.353  0.9849
##  UK - LK     -3.06 6.84 1498  -0.448  0.9701
##  MK - LK     -5.57 5.99 1498  -0.929  0.7894
## 
## Results are averaged over the levels of: Zone 
## P value adjustment: tukey method for comparing a family of 4 estimates
# Inshore data 
TA_sal_model_in<-lm(TA_umol_kg~BestSalinity * Sub_region,
                     data=FLK.data[FLK.data$Zone=="Inshore", ])
    anova(TA_sal_model_in)
    summary(TA_sal_model_in)
## 
## Call:
## lm(formula = TA_umol_kg ~ BestSalinity * Sub_region, data = FLK.data[FLK.data$Zone == 
##     "Inshore", ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -359.53  -45.74    7.03   54.00  355.76 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               3405.556    396.791   8.583  < 2e-16 ***
## BestSalinity               -28.873     11.078  -2.606  0.00947 ** 
## Sub_regionUK              -381.934    535.109  -0.714  0.47576    
## Sub_regionMK              -264.850    459.418  -0.576  0.56458    
## Sub_regionLK              -936.625    492.630  -1.901  0.05793 .  
## BestSalinity:Sub_regionUK   11.017     14.895   0.740  0.45993    
## BestSalinity:Sub_regionMK    6.812     12.799   0.532  0.59485    
## BestSalinity:Sub_regionLK   24.160     13.712   1.762  0.07878 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 92.82 on 435 degrees of freedom
##   (2 observations deleted due to missingness)
## Multiple R-squared:  0.1502, Adjusted R-squared:  0.1365 
## F-statistic: 10.98 on 7 and 435 DF,  p-value: 8.504e-13
    m.lst <- lstrends(TA_sal_model_in, "Sub_region", var="BestSalinity") 
    pairs(m.lst)
##  contrast estimate   SE  df t.ratio p.value
##  BB - UK    -11.02 14.9 435  -0.740  0.8810
##  BB - MK     -6.81 12.8 435  -0.532  0.9512
##  BB - LK    -24.16 13.7 435  -1.762  0.2932
##  UK - MK      4.20 11.8 435   0.355  0.9846
##  UK - LK    -13.14 12.8 435  -1.025  0.7349
##  MK - LK    -17.35 10.3 435  -1.682  0.3344
## 
## P value adjustment: tukey method for comparing a family of 4 estimates

3.2.1 Salinity DIC: Model II OLS regressions

  • Salinity-DIC plots by zone
DIC_Sal<- ggplot(FLK.data) + MyTheme+
  geom_point(aes (BestSalinity, DIC_umol_kg, fill=Season, shape=Zone),
             alpha=0.7, size=1)+
  geom_smooth(aes(BestSalinity, DIC_umol_kg),
              linetype=1, method = "lm", color="black")+
  Season_fill+
  guides(shape="none")+
  Zone_shapes4+
  scale_y_continuous(#limits = c(1700, 2400),
                     expand = c(0.3, 0.02),
                     name=expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
  scale_x_continuous(#limits = c(1700, 2400),
                     expand = c(0.02, 0.02),
                     name=expression(paste("Salinity")))
DIC_Sal+ facet_grid(~Zone)

  • Sal-DIC: Model II OLS regressions by zone
DIC_coef_OLS <- FLK.data %>%
                  group_by(Zone) %>%
                  do({model = lm(DIC_umol_kg~BestSalinity, data=.)
                  # create model
                  data.frame(tidy(model), # get coefficient info
                  glance(model))})        # get model info
  #DIC_coef_OLS
  
  kable(as.data.frame(DIC_coef_OLS[,1:9], format = "markdown"), 
      caption = "Table: DIC vs salinity model II regressions by zone",
      digits = 3)%>% 
  kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table: DIC vs salinity model II regressions by zone
Zone term estimate std.error statistic p.value r.squared adj.r.squared sigma
Inshore (Intercept) 3548.395 159.433 22.256 0.000 0.172 0.170 101.394
Inshore BestSalinity -42.347 4.424 -9.572 0.000 0.172 0.170 101.394
Mid channel (Intercept) 2563.242 150.741 17.004 0.000 0.029 0.027 60.242
Mid channel BestSalinity -14.609 4.187 -3.489 0.001 0.029 0.027 60.242
Offshore (Intercept) 1873.124 84.496 22.168 0.000 0.009 0.007 30.493
Offshore BestSalinity 4.838 2.348 2.060 0.040 0.009 0.007 30.493
Oceanic (Intercept) 1831.926 96.057 19.071 0.000 0.025 0.020 22.580
Oceanic BestSalinity 5.982 2.670 2.241 0.026 0.025 0.020 22.580
  #write.csv(DIC_coef_OLS, "FLK_results/DIC_Sal.csv")

Are DIC vs Temperature slopes different in each zone?

# Are the slopes different? 
DIC_sal_model<-lm(DIC_umol_kg~BestSalinity * Zone, data=FLK.data)
    anova(DIC_sal_model)
    summary(DIC_sal_model)
## 
## Call:
## lm(formula = DIC_umol_kg ~ BestSalinity * Zone, data = FLK.data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -360.13  -22.01    0.35   25.67  303.27 
## 
## Coefficients:
##                               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                   3548.395    103.165  34.395  < 2e-16 ***
## BestSalinity                   -42.347      2.863 -14.792  < 2e-16 ***
## ZoneMid channel               -985.153    193.896  -5.081 4.22e-07 ***
## ZoneOffshore                 -1675.272    209.033  -8.014 2.19e-15 ***
## ZoneOceanic                  -1716.469    297.563  -5.768 9.68e-09 ***
## BestSalinity:ZoneMid channel    27.738      5.384   5.152 2.92e-07 ***
## BestSalinity:ZoneOffshore       47.185      5.807   8.126 9.10e-16 ***
## BestSalinity:ZoneOceanic        48.329      8.270   5.844 6.21e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 65.61 on 1520 degrees of freedom
##   (10 observations deleted due to missingness)
## Multiple R-squared:  0.1494, Adjusted R-squared:  0.1454 
## F-statistic: 38.13 on 7 and 1520 DF,  p-value: < 2.2e-16
    # DIC_sal_aov<-aov(DIC_sal_model)
    # DIC_PostH<-TukeyHSD(DIC_sal_aov, c("Sub_region", "Zone"), ordered = TRUE)
    # DIC_PostH
    m.lst <- lstrends(DIC_sal_model, "Zone", var="BestSalinity") 
    pairs(m.lst)
##  contrast               estimate   SE   df t.ratio p.value
##  Inshore - Mid channel    -27.74 5.38 1520  -5.152  <.0001
##  Inshore - Offshore       -47.18 5.81 1520  -8.126  <.0001
##  Inshore - Oceanic        -48.33 8.27 1520  -5.844  <.0001
##  Mid channel - Offshore   -19.45 6.81 1520  -2.858  0.0225
##  Mid channel - Oceanic    -20.59 9.00 1520  -2.288  0.1012
##  Offshore - Oceanic        -1.14 9.26 1520  -0.124  0.9993
## 
## P value adjustment: tukey method for comparing a family of 4 estimates

Salinity-DIC plots by region and zone

DIC_Sal_Reg<- ggplot(FLK.data) + MyTheme+
  geom_point(aes (BestSalinity, DIC_umol_kg, fill=Sub_region, shape=Zone),
             alpha=0.6, size=.8)+
  geom_smooth(aes(BestSalinity, DIC_umol_kg, colour=Sub_region),
              linetype=1, method = "lm", se=F)+
  geom_smooth(aes(BestSalinity, DIC_umol_kg),
              linetype=1, method = "lm", colour="black")+
  #Precipitation_fill+
  Zone_shapes4+
  guides(shape="none")+
  scale_y_continuous(#limits = c(1700, 2400),
                     expand = c(0.3, 0.02),
                     name=expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
  scale_x_continuous(#limits = c(1700, 2400),
                     expand = c(0.02, 0.02),
                     name=expression(paste("Salinity")))
DIC_Sal_Reg + facet_grid(~Zone)

  • Salinity-DIC: Model II OLS regressions by region and zone
DIC_coef_OLS <- FLK.data %>%
                  group_by(Sub_region, Zone) %>%
                  do({model = lm(DIC_umol_kg~BestSalinity, data=.)
                  # create model
                  data.frame(tidy(model), # get coefficient info
                  glance(model))})        # get model info
  #DIC_coef_OLS
  
  kable(as.data.frame(DIC_coef_OLS[,1:9], format = "markdown"), 
      caption = "Table: DIC vs salinity model II regressions by region and zone",
      digits = 3)%>% 
  kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table: DIC vs salinity model II regressions by region and zone
Sub_region Zone term estimate std.error statistic p.value r.squared adj.r.squared
BB Inshore (Intercept) 4419.643 285.517 15.479 0.000 0.459 0.452
BB Inshore BestSalinity -66.065 7.971 -8.288 0.000 0.459 0.452
BB Mid channel (Intercept) 2732.703 247.874 11.025 0.000 0.094 0.081
BB Mid channel BestSalinity -18.890 6.882 -2.745 0.008 0.094 0.081
BB Offshore (Intercept) 2147.108 129.013 16.643 0.000 0.007 -0.005
BB Offshore BestSalinity -2.692 3.589 -0.750 0.455 0.007 -0.005
UK Inshore (Intercept) 4126.363 369.762 11.160 0.000 0.236 0.228
UK Inshore BestSalinity -57.853 10.261 -5.638 0.000 0.236 0.228
UK Mid channel (Intercept) 2770.153 273.300 10.136 0.000 0.094 0.080
UK Mid channel BestSalinity -20.117 7.595 -2.649 0.010 0.094 0.080
UK Offshore (Intercept) 1888.997 147.746 12.785 0.000 0.011 0.001
UK Offshore BestSalinity 4.412 4.103 1.075 0.285 0.011 0.001
UK Oceanic (Intercept) 1856.885 206.415 8.996 0.000 0.023 -0.005
UK Oceanic BestSalinity 5.187 5.753 0.902 0.374 0.023 -0.005
MK Inshore (Intercept) 3350.732 271.880 12.324 0.000 0.166 0.159
MK Inshore BestSalinity -37.139 7.532 -4.931 0.000 0.166 0.159
MK Mid channel (Intercept) 2487.296 272.717 9.120 0.000 0.022 0.015
MK Mid channel BestSalinity -12.769 7.568 -1.687 0.094 0.022 0.015
MK Offshore (Intercept) 1786.115 179.931 9.927 0.000 0.016 0.008
MK Offshore BestSalinity 7.058 5.002 1.411 0.161 0.016 0.008
MK Oceanic (Intercept) 2000.013 178.096 11.230 0.000 0.001 -0.012
MK Oceanic BestSalinity 1.322 4.947 0.267 0.790 0.001 -0.012
LK Inshore (Intercept) 2806.550 320.865 8.747 0.000 0.047 0.039
LK Inshore BestSalinity -22.362 8.883 -2.517 0.013 0.047 0.039
LK Mid channel (Intercept) 2512.523 292.251 8.597 0.000 0.020 0.013
LK Mid channel BestSalinity -13.312 8.124 -1.639 0.104 0.020 0.013
LK Offshore (Intercept) 1791.911 165.284 10.841 0.000 0.015 0.009
LK Offshore BestSalinity 7.190 4.591 1.566 0.119 0.015 0.009
LK Oceanic (Intercept) 1707.487 138.076 12.366 0.000 0.070 0.059
LK Oceanic BestSalinity 9.475 3.837 2.470 0.016 0.070 0.059
  #write.csv(DIC_coef_OLS, "FLK_results/DIC_Sal.csv")
  • Are DIC vs Salinity slopes different by region?
# Are the slopes different? 
DIC_sal_model<-lm(DIC_umol_kg~BestSalinity * Sub_region * Zone, data=FLK.data)
    anova(DIC_sal_model)
    summary(DIC_sal_model)
## 
## Call:
## lm(formula = DIC_umol_kg ~ BestSalinity * Sub_region * Zone, 
##     data = FLK.data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -321.07  -23.16   -0.58   25.16  303.09 
## 
## Coefficients: (2 not defined because of singularities)
##                                            Estimate Std. Error t value Pr(>|t|)
## (Intercept)                                4419.643    275.591  16.037  < 2e-16
## BestSalinity                                -66.065      7.694  -8.586  < 2e-16
## Sub_regionUK                               -293.280    365.748  -0.802  0.42276
## Sub_regionMK                              -1068.911    316.129  -3.381  0.00074
## Sub_regionLK                              -1613.093    342.613  -4.708 2.73e-06
## ZoneMid channel                           -1686.940    551.750  -3.057  0.00227
## ZoneOffshore                              -2272.535    492.832  -4.611 4.34e-06
## ZoneOceanic                               -1099.064    473.604  -2.321  0.02044
## BestSalinity:Sub_regionUK                     8.212     10.185   0.806  0.42020
## BestSalinity:Sub_regionMK                    28.926      8.810   3.283  0.00105
## BestSalinity:Sub_regionLK                    43.703      9.537   4.582 4.98e-06
## BestSalinity:ZoneMid channel                 47.174     15.341   3.075  0.00214
## BestSalinity:ZoneOffshore                    63.373     13.725   4.617 4.22e-06
## BestSalinity:ZoneOceanic                     31.837     13.151   2.421  0.01560
## Sub_regionUK:ZoneMid channel                330.730    762.131   0.434  0.66438
## Sub_regionMK:ZoneMid channel                823.504    626.625   1.314  0.18898
## Sub_regionLK:ZoneMid channel               1392.913    646.546   2.154  0.03137
## Sub_regionUK:ZoneOffshore                    35.169    688.503   0.051  0.95927
## Sub_regionMK:ZoneOffshore                   707.918    614.952   1.151  0.24984
## Sub_regionLK:ZoneOffshore                  1257.896    615.739   2.043  0.04124
## Sub_regionUK:ZoneOceanic                  -1170.414    742.638  -1.576  0.11523
## Sub_regionMK:ZoneOceanic                   -251.655    703.838  -0.358  0.72073
## Sub_regionLK:ZoneOceanic                         NA         NA      NA       NA
## BestSalinity:Sub_regionUK:ZoneMid channel    -9.439     21.183  -0.446  0.65595
## BestSalinity:Sub_regionMK:ZoneMid channel   -22.805     17.413  -1.310  0.19052
## BestSalinity:Sub_regionLK:ZoneMid channel   -38.124     17.968  -2.122  0.03402
## BestSalinity:Sub_regionUK:ZoneOffshore       -1.108     19.146  -0.058  0.95385
## BestSalinity:Sub_regionMK:ZoneOffshore      -19.176     17.112  -1.121  0.26262
## BestSalinity:Sub_regionLK:ZoneOffshore      -33.821     17.126  -1.975  0.04847
## BestSalinity:Sub_regionUK:ZoneOceanic        31.203     20.657   1.511  0.13111
## BestSalinity:Sub_regionMK:ZoneOceanic         6.624     19.544   0.339  0.73471
## BestSalinity:Sub_regionLK:ZoneOceanic            NA         NA      NA       NA
##                                              
## (Intercept)                               ***
## BestSalinity                              ***
## Sub_regionUK                                 
## Sub_regionMK                              ***
## Sub_regionLK                              ***
## ZoneMid channel                           ** 
## ZoneOffshore                              ***
## ZoneOceanic                               *  
## BestSalinity:Sub_regionUK                    
## BestSalinity:Sub_regionMK                 ** 
## BestSalinity:Sub_regionLK                 ***
## BestSalinity:ZoneMid channel              ** 
## BestSalinity:ZoneOffshore                 ***
## BestSalinity:ZoneOceanic                  *  
## Sub_regionUK:ZoneMid channel                 
## Sub_regionMK:ZoneMid channel                 
## Sub_regionLK:ZoneMid channel              *  
## Sub_regionUK:ZoneOffshore                    
## Sub_regionMK:ZoneOffshore                    
## Sub_regionLK:ZoneOffshore                 *  
## Sub_regionUK:ZoneOceanic                     
## Sub_regionMK:ZoneOceanic                     
## Sub_regionLK:ZoneOceanic                     
## BestSalinity:Sub_regionUK:ZoneMid channel    
## BestSalinity:Sub_regionMK:ZoneMid channel    
## BestSalinity:Sub_regionLK:ZoneMid channel *  
## BestSalinity:Sub_regionUK:ZoneOffshore       
## BestSalinity:Sub_regionMK:ZoneOffshore       
## BestSalinity:Sub_regionLK:ZoneOffshore    *  
## BestSalinity:Sub_regionUK:ZoneOceanic        
## BestSalinity:Sub_regionMK:ZoneOceanic        
## BestSalinity:Sub_regionLK:ZoneOceanic        
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 64.47 on 1498 degrees of freedom
##   (10 observations deleted due to missingness)
## Multiple R-squared:  0.1906, Adjusted R-squared:  0.175 
## F-statistic: 12.17 on 29 and 1498 DF,  p-value: < 2.2e-16
    # DIC_sal_aov<-aov(DIC_sal_model)
    # DIC_PostH<-TukeyHSD(DIC_sal_aov, c("Sub_region", "Zone"), ordered = TRUE)
    # DIC_PostH
    m.lst <- lstrends(DIC_sal_model, "Sub_region", var="BestSalinity") 
    pairs(m.lst)
##  contrast estimate   SE   df t.ratio p.value
##  BB - UK    nonEst   NA   NA      NA      NA
##  BB - MK    nonEst   NA   NA      NA      NA
##  BB - LK    nonEst   NA   NA      NA      NA
##  UK - MK     -6.71 7.50 1498  -0.894  0.8078
##  UK - LK    -12.34 7.32 1498  -1.685  0.3319
##  MK - LK     -5.63 6.36 1498  -0.886  0.8123
## 
## Results are averaged over the levels of: Zone 
## P value adjustment: tukey method for comparing a family of 4 estimates
DIC_sal_model_in<-lm(DIC_umol_kg~BestSalinity * Sub_region,
                     data=FLK.data[FLK.data$Zone=="Inshore", ])
    anova(DIC_sal_model_in)
    summary(DIC_sal_model_in)
## 
## Call:
## lm(formula = DIC_umol_kg ~ BestSalinity * Sub_region, data = FLK.data[FLK.data$Zone == 
##     "Inshore", ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -321.07  -64.73   -1.49   62.41  303.09 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                4419.643    423.449  10.437  < 2e-16 ***
## BestSalinity                -66.065     11.822  -5.588 4.06e-08 ***
## Sub_regionUK               -293.280    561.978  -0.522  0.60203    
## Sub_regionMK              -1068.911    485.738  -2.201  0.02829 *  
## Sub_regionLK              -1613.093    526.430  -3.064  0.00232 ** 
## BestSalinity:Sub_regionUK     8.212     15.649   0.525  0.60002    
## BestSalinity:Sub_regionMK    28.926     13.536   2.137  0.03316 *  
## BestSalinity:Sub_regionLK    43.703     14.654   2.982  0.00302 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 99.05 on 435 degrees of freedom
##   (2 observations deleted due to missingness)
## Multiple R-squared:  0.2206, Adjusted R-squared:  0.208 
## F-statistic: 17.58 on 7 and 435 DF,  p-value: < 2.2e-16
    m.lst <- lstrends(DIC_sal_model_in, "Sub_region", var="BestSalinity") 
    pairs(m.lst)
##  contrast estimate   SE  df t.ratio p.value
##  BB - UK     -8.21 15.6 435  -0.525  0.9531
##  BB - MK    -28.93 13.5 435  -2.137  0.1431
##  BB - LK    -43.70 14.7 435  -2.982  0.0159
##  UK - MK    -20.71 12.2 435  -1.699  0.3253
##  UK - LK    -35.49 13.4 435  -2.645  0.0420
##  MK - LK    -14.78 10.9 435  -1.358  0.5266
## 
## P value adjustment: tukey method for comparing a family of 4 estimates

3.2.3 TA/DIC salinity

  • TA/DIC salinity plot by zone
FLK.data$TA_DIC<-FLK.data$TA_umol_kg/FLK.data$DIC_umol_kg

TA_DIC_Sal<- ggplot(FLK.data) + MyTheme+
  geom_point(aes (BestSalinity, TA_DIC, fill=Season, shape=Zone),
             alpha=0.6, size=.8)+
  # geom_smooth(aes(BestSalinity, TA_DIC, colour=Sub_region),
  #             linetype=1, method = "lm", se=F)+
   geom_smooth(aes(BestSalinity, TA_DIC),
               linetype=1, method = "lm", colour="black")+
  Zone_shapes4+
  Season_fill+
  guides(shape="none")+
  scale_y_continuous(#limits = c(1700, 2400),
                     expand = c(0.02, 0.02),
                     name=expression(paste("TA/DIC")))+
  scale_x_continuous(#limits = c(1700, 2400),
                     expand = c(0.02, 0.02),
                     name=expression(paste("Salinity")))
TA_DIC_Sal + facet_grid(~Zone)

  • TA/DIC vs Salinity: Model II OLS regressions by zone
##TA/DIC vs sal by zone
TA_DIC_Sal_Z <- FLK.data %>%
                  group_by(Zone) %>%
                  do({model = lm(TA_DIC~BestSalinity, data=.)
                  # create model
                  data.frame(tidy(model), # get coefficient info
                  glance(model))})        # get model info
#TA_DIC_Sal_Z
  
kable(as.data.frame(TA_DIC_Sal_Z[,1:8], format = "markdown"), 
      caption = "Table: TA/DIC vs salinity by zone",
      digits = 3)%>% 
      kable_styling(bootstrap_options = c("striped", "condensed", 
                                      full_width = F), font_size = 11)
Table: TA/DIC vs salinity by zone
Zone term estimate std.error statistic p.value r.squared adj.r.squared
Inshore (Intercept) 0.566 0.044 12.958 0.000 0.296 0.295
Inshore BestSalinity 0.016 0.001 13.593 0.000 0.296 0.295
Mid channel (Intercept) 0.653 0.039 16.795 0.000 0.298 0.296
Mid channel BestSalinity 0.014 0.001 13.070 0.000 0.298 0.296
Offshore (Intercept) 1.072 0.028 38.142 0.000 0.021 0.019
Offshore BestSalinity 0.002 0.001 3.185 0.002 0.021 0.019
Oceanic (Intercept) 1.148 0.040 28.507 0.000 0.001 -0.004
Oceanic BestSalinity 0.000 0.001 0.383 0.702 0.001 -0.004
#write.csv(TA_DIC_Sal_Z, "FLK_results/TA_DIC_Z.csv")
  • TA/DIC salinity plot by region and zone
FLK.data$TA_DIC<-FLK.data$TA_umol_kg/FLK.data$DIC_umol_kg

TA_DIC_Sal_re<- ggplot(FLK.data) + MyTheme+
  geom_point(aes (BestSalinity, TA_DIC, fill=Sub_region, shape=Zone),
             alpha=0.6, size=.8)+
   geom_smooth(aes(BestSalinity, TA_DIC, colour=Sub_region),
               linetype=1, method = "lm", se=F)+
   geom_smooth(aes(BestSalinity, TA_DIC),
               linetype=1, method = "lm", colour="black")+
  Zone_shapes4+
  #Season_fill+
  guides(shape="none")+
  scale_y_continuous(#limits = c(1700, 2400),
                     expand = c(0.02, 0.02),
                     name=expression(paste("TA/DIC")))+
  scale_x_continuous(#limits = c(1700, 2400),
                     expand = c(0.02, 0.02),
                     name=expression(paste("Salinity")))
TA_DIC_Sal_re + facet_grid(~Zone)

  • TA/DIC vs Salinity: Model II OLS regressions by zone and region
#TA/DIC vs sal by regions and zone
TADIC_Sal <- FLK.data %>%
                  group_by(Sub_region, Zone) %>%
                  do({model = lm(TA_DIC~BestSalinity, data=.)
                  # create model
                  data.frame(tidy(model), # get coefficient info
                  glance(model))})        # get model info
#TADIC_Sal
  
kable(as.data.frame(TADIC_Sal[,1:8], format = "markdown"), 
      caption = "Table: TA/DIC vs salinity by zone and region",
      digits = 3)%>% 
      kable_styling(bootstrap_options = c("striped", "condensed", 
                                      full_width = F), font_size = 11)
Table: TA/DIC vs salinity by zone and region
Sub_region Zone term estimate std.error statistic p.value r.squared
BB Inshore (Intercept) 0.320 0.080 4.004 0.000 0.574
BB Inshore BestSalinity 0.023 0.002 10.444 0.000 0.574
BB Mid channel (Intercept) 0.642 0.083 7.735 0.000 0.346
BB Mid channel BestSalinity 0.014 0.002 6.218 0.000 0.346
BB Offshore (Intercept) 1.107 0.056 19.686 0.000 0.011
BB Offshore BestSalinity 0.001 0.002 0.948 0.346 0.011
UK Inshore (Intercept) 0.192 0.110 1.751 0.083 0.436
UK Inshore BestSalinity 0.027 0.003 8.877 0.000 0.436
UK Mid channel (Intercept) 0.533 0.110 4.837 0.000 0.325
UK Mid channel BestSalinity 0.018 0.003 5.724 0.000 0.325
UK Offshore (Intercept) 1.045 0.063 16.665 0.000 0.031
UK Offshore BestSalinity 0.003 0.002 1.856 0.066 0.031
UK Oceanic (Intercept) 1.016 0.078 13.048 0.000 0.099
UK Oceanic BestSalinity 0.004 0.002 1.905 0.065 0.099
MK Inshore (Intercept) 0.705 0.071 9.988 0.000 0.262
MK Inshore BestSalinity 0.013 0.002 6.547 0.000 0.262
MK Mid channel (Intercept) 0.649 0.067 9.640 0.000 0.323
MK Mid channel BestSalinity 0.014 0.002 7.661 0.000 0.323
MK Offshore (Intercept) 1.086 0.058 18.775 0.000 0.014
MK Offshore BestSalinity 0.002 0.002 1.334 0.185 0.014
MK Oceanic (Intercept) 1.162 0.073 15.893 0.000 0.000
MK Oceanic BestSalinity 0.000 0.002 0.020 0.984 0.000
LK Inshore (Intercept) 0.724 0.078 9.282 0.000 0.190
LK Inshore BestSalinity 0.012 0.002 5.493 0.000 0.190
LK Mid channel (Intercept) 0.712 0.065 10.942 0.000 0.263
LK Mid channel BestSalinity 0.012 0.002 6.862 0.000 0.263
LK Offshore (Intercept) 1.052 0.047 22.201 0.000 0.031
LK Offshore BestSalinity 0.003 0.001 2.260 0.025 0.031
LK Oceanic (Intercept) 1.222 0.062 19.770 0.000 0.011
LK Oceanic BestSalinity -0.002 0.002 -0.965 0.337 0.011
#write.csv(TADIC_Sal, "FLK_results/TA_DIC_all.csv")
  • Are the TA/DIC slopes different?
TA_DIA_sal_model<-lm(TA_DIC~BestSalinity * Sub_region * Zone, data=FLK.data)
    anova(TA_DIA_sal_model)
    #summary(TA_DIA_sal_model)
    # DIC_sal_aov<-aov(TA_DIA_sal_model)
    # TADIC_PostH<-TukeyHSD(DIC_sal_aov, c("Sub_region", "Zone"), ordered = TRUE)
    # TADIC_PostH
    m.lst <- lstrends(TA_DIA_sal_model, "Sub_region", var="BestSalinity") 
    pairs(m.lst)
##  contrast estimate      SE   df t.ratio p.value
##  BB - UK    nonEst      NA   NA      NA      NA
##  BB - MK    nonEst      NA   NA      NA      NA
##  BB - LK    nonEst      NA   NA      NA      NA
##  UK - MK  0.005664 0.00204 1489   2.770  0.0290
##  UK - LK  0.006590 0.00197 1489   3.346  0.0047
##  MK - LK  0.000926 0.00173 1489   0.536  0.9502
## 
## Results are averaged over the levels of: Zone 
## P value adjustment: tukey method for comparing a family of 4 estimates
TA_DIA_sal_model_in<-lm(TA_DIC~BestSalinity * Sub_region, 
                     data=FLK.data[FLK.data$Zone=="Inshore",])
    anova(TA_DIA_sal_model_in)
    #summary(TA_DIA_sal_model_in)
    m.lst <- lstrends(TA_DIA_sal_model_in, "Sub_region", var="BestSalinity") 
    pairs(m.lst)
##  contrast  estimate      SE  df t.ratio p.value
##  BB - UK  -0.003714 0.00413 433  -0.900  0.8046
##  BB - MK   0.010537 0.00354 433   2.973  0.0164
##  BB - LK   0.011470 0.00380 433   3.016  0.0144
##  UK - MK   0.014251 0.00328 433   4.345  0.0001
##  UK - LK   0.015184 0.00356 433   4.268  0.0001
##  MK - LK   0.000932 0.00286 433   0.326  0.9881
## 
## P value adjustment: tukey method for comparing a family of 4 estimates

Figure 4: Summary by zone and season

Temperature

Tem_Zone<-ggarrange(Tep_Sal_Sea + facet_grid(~Zone) +
                            guides(fill = guide_legend(
                              override.aes=list(shape=21)),
                              shape = "none")+
                              theme(axis.title.x=element_blank(),
                                  axis.text.x=element_blank(),
                                  axis.ticks.x=element_blank()),
                          TA_Tem + facet_grid(~Zone)+
                              theme(legend.position = "none",
                                  strip.text.x = element_blank(),
                                  axis.title.x=element_blank(),
                                  axis.text.x=element_blank(),
                                  axis.ticks.x=element_blank()),
                          DIC_Tem + facet_grid(~Zone)+
                              theme(legend.position = "none",
                                  strip.text.x = element_blank(),
                                  axis.text.x = element_text(angle = 0)), 
          #labels = c("A", "B"),
          ncol = 1, nrow = 3, heights = c(1, .7, .9))
Tem_Zone

# Temp sal
    TS_coef_OLS <- FLK.data %>%
                    group_by(Zone) %>%
                    do({model = lm(BestSalinity~Temperature_C, data=.)  # model
                        data.frame(tidy(model), # get coefficient info
                        glance(model))})        # get model info
    kable(as.data.frame(TS_coef_OLS[,1:9], format = "markdown"), 
          caption = "Table: Salinity vs Temperature linear regressions by zone",
          digits = 3)%>% 
    kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table: Salinity vs Temperature linear regressions by zone
Zone term estimate std.error statistic p.value r.squared adj.r.squared sigma
Inshore (Intercept) 34.798 0.388 89.776 0.000 0.022 0.020 1.078
Inshore Temperature_C 0.046 0.014 3.190 0.002 0.022 0.020 1.078
Mid channel (Intercept) 36.416 0.326 111.832 0.000 0.004 0.002 0.714
Mid channel Temperature_C -0.015 0.012 -1.295 0.196 0.004 0.002 0.714
Offshore (Intercept) 37.949 0.282 134.547 0.000 0.092 0.090 0.563
Offshore Temperature_C -0.072 0.010 -6.995 0.000 0.092 0.090 0.563
Oceanic (Intercept) 39.049 0.449 86.979 0.000 0.194 0.190 0.541
Oceanic Temperature_C -0.112 0.016 -6.879 0.000 0.194 0.190 0.541
# Temp TA
    TA_coef_OLS <- FLK.data %>%
                    group_by(Zone) %>%
                    do({model = lm(TA_umol_kg~Temperature_C, data=.)  # model
                        data.frame(tidy(model), # get coefficient info
                        glance(model))})        # get model info
    kable(as.data.frame(TA_coef_OLS[,1:9], format = "markdown"), 
          caption = "Table: TA vs Temperature linear regressions by zone",
          digits = 3)%>% 
    kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table: TA vs Temperature linear regressions by zone
Zone term estimate std.error statistic p.value r.squared adj.r.squared sigma
Inshore (Intercept) 2798.372 28.592 97.872 0 0.368 0.367 79.490
Inshore Temperature_C -16.946 1.057 -16.028 0 0.368 0.367 79.490
Mid channel (Intercept) 2634.359 21.862 120.501 0 0.275 0.274 47.919
Mid channel Temperature_C -9.911 0.800 -12.389 0 0.275 0.274 47.919
Offshore (Intercept) 2502.306 12.432 201.274 0 0.175 0.174 24.776
Offshore Temperature_C -4.578 0.453 -10.106 0 0.175 0.174 24.776
Oceanic (Intercept) 2421.972 10.730 225.711 0 0.068 0.064 12.937
Oceanic Temperature_C -1.476 0.390 -3.780 0 0.068 0.064 12.937
# Temp DIC
    DIC_coef_OLS <- FLK.data %>%
                    group_by(Zone) %>%
                    do({model = lm(DIC_umol_kg~Temperature_C, data=.)  # model
                        data.frame(tidy(model), # get coefficient info
                        glance(model))})        # get model info
    kable(as.data.frame(DIC_coef_OLS[,1:9], format = "markdown"), 
          caption = "Table: DIC vs Temperature linear regressions by zone",
          digits = 3)%>% 
    kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table: DIC vs Temperature linear regressions by zone
Zone term estimate std.error statistic p.value r.squared adj.r.squared sigma
Inshore (Intercept) 2498.372 33.146 75.374 0 0.322 0.320 91.764
Inshore Temperature_C -17.752 1.227 -14.466 0 0.322 0.320 91.764
Mid channel (Intercept) 2337.591 23.609 99.013 0 0.289 0.287 51.566
Mid channel Temperature_C -11.060 0.865 -12.792 0 0.289 0.287 51.566
Offshore (Intercept) 2198.529 13.777 159.585 0 0.202 0.200 27.362
Offshore Temperature_C -5.543 0.502 -11.030 0 0.202 0.200 27.362
Oceanic (Intercept) 2125.476 18.299 116.150 0 0.087 0.082 21.857
Oceanic Temperature_C -2.864 0.666 -4.298 0 0.087 0.082 21.857

Salinity

Salinity_Zone<-ggarrange(TA_DIC_Sal + facet_grid(~Zone) +
                            guides(fill = guide_legend(
                              override.aes=list(shape=21)),
                              shape = "none")+
                              theme(axis.title.x=element_blank(),
                                  axis.text.x=element_blank(),
                                  axis.ticks.x=element_blank()),
                          TA_Sal + facet_grid(~Zone)+
                              theme(legend.position = "none",
                                  strip.text.x = element_blank(),
                                  axis.title.x=element_blank(),
                                  axis.text.x=element_blank(),
                                  axis.ticks.x=element_blank()),
                          DIC_Sal + facet_grid(~Zone)+
                              theme(legend.position = "none",
                                  strip.text.x = element_blank(),
                                  axis.text.x = element_text(angle = 0)), 
          #labels = c("A", "B"),
          ncol = 1, nrow = 3, heights = c(1, .7, .9))
Salinity_Zone

##TA/DIC vs sal by zone
    TA_DIC_Sal_Z <- FLK.data %>%
                      group_by(Zone) %>%
                      do({model = lm(TA_DIC~BestSalinity, data=.)
                      # create model
                      data.frame(tidy(model), # get coefficient info
                      glance(model))})        # get model info
    kable(as.data.frame(TA_DIC_Sal_Z[,1:8], format = "markdown"), 
          caption = "Table: TA/DIC vs salinity by zone",
          digits = 3)%>% 
          kable_styling(bootstrap_options = c("striped", "condensed", 
                                      full_width = F), font_size = 11)
Table: TA/DIC vs salinity by zone
Zone term estimate std.error statistic p.value r.squared adj.r.squared
Inshore (Intercept) 0.566 0.044 12.958 0.000 0.296 0.295
Inshore BestSalinity 0.016 0.001 13.593 0.000 0.296 0.295
Mid channel (Intercept) 0.653 0.039 16.795 0.000 0.298 0.296
Mid channel BestSalinity 0.014 0.001 13.070 0.000 0.298 0.296
Offshore (Intercept) 1.072 0.028 38.142 0.000 0.021 0.019
Offshore BestSalinity 0.002 0.001 3.185 0.002 0.021 0.019
Oceanic (Intercept) 1.148 0.040 28.507 0.000 0.001 -0.004
Oceanic BestSalinity 0.000 0.001 0.383 0.702 0.001 -0.004
##TA
    TA_coef_Zone <- FLK.data %>%
                group_by(Zone) %>%
                      do({model = lm(TA_umol_kg~BestSalinity, data=.)
                      # create model
                      data.frame(tidy(model), # get coefficient info
                      glance(model))})        # get model info
    kable(as.data.frame(TA_coef_Zone[,1:8], format = "markdown"), 
          caption = "Table 1: TA vs salinity by zone",
          digits = 3)%>% 
      kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table 1: TA vs salinity by zone
Zone term estimate std.error statistic p.value r.squared adj.r.squared
Inshore (Intercept) 3044.292 156.999 19.391 0.000 0.043 0.041
Inshore BestSalinity -19.429 4.354 -4.462 0.000 0.043 0.041
Mid channel (Intercept) 2012.916 142.211 14.154 0.000 0.015 0.013
Mid channel BestSalinity 9.782 3.949 2.477 0.014 0.015 0.013
Offshore (Intercept) 2034.277 74.934 27.148 0.000 0.042 0.040
Offshore BestSalinity 9.529 2.082 4.577 0.000 0.042 0.040
Oceanic (Intercept) 2081.902 53.880 38.640 0.000 0.137 0.133
Oceanic BestSalinity 8.328 1.497 5.562 0.000 0.137 0.133
    #write.csv(TA_coef_Zone, "FLK_results/TA_Sal_Zone.csv")

## DIC
    DIC_coef_Zone <- FLK.data %>%
                      group_by(Zone) %>%
                      do({model = lm(DIC_umol_kg~BestSalinity, data=.)
                      # create model
                      data.frame(tidy(model), # get coefficient info
                      glance(model))})        # get model info
    kable(as.data.frame(DIC_coef_Zone[,1:9], format = "markdown"), 
          caption = "Table 1: DIC vs salinity by zone",
          digits = 3)%>% 
    kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table 1: DIC vs salinity by zone
Zone term estimate std.error statistic p.value r.squared adj.r.squared sigma
Inshore (Intercept) 3548.395 159.433 22.256 0.000 0.172 0.170 101.394
Inshore BestSalinity -42.347 4.424 -9.572 0.000 0.172 0.170 101.394
Mid channel (Intercept) 2563.242 150.741 17.004 0.000 0.029 0.027 60.242
Mid channel BestSalinity -14.609 4.187 -3.489 0.001 0.029 0.027 60.242
Offshore (Intercept) 1873.124 84.496 22.168 0.000 0.009 0.007 30.493
Offshore BestSalinity 4.838 2.348 2.060 0.040 0.009 0.007 30.493
Oceanic (Intercept) 1831.926 96.057 19.071 0.000 0.025 0.020 22.580
Oceanic BestSalinity 5.982 2.670 2.241 0.026 0.025 0.020 22.580
    #write.csv(DIC_coef_Zone, "FLK_results/DIC_Sal_Zone.csv")
Zone_Plot<-ggarrange(Tem_Zone, Salinity_Zone,  ncol = 2 )
Zone_Plot

#ggsave(file="FLK_results/Sal_Te_Zone.svg", plot=Zone, dpi = 300, width=8, height=5)

##Figure 4: Summary salinity plots with region

  • TA and DIC vs Salinity (region and zone) - no season
Salinity_Region<-ggarrange(TA_Sal_Reg + facet_grid(~Zone) +
                              guides(fill = guide_legend(
                              override.aes=list(shape=21)),
                              shape = "none")+
                              theme(axis.title.x=element_blank(),
                                  axis.text.x=element_blank(),
                                  axis.ticks.x=element_blank()),
                          DIC_Sal_Reg + facet_grid(~Zone)+
                              theme(legend.position = "none",
                                  strip.text.x = element_blank(),
                                  axis.text.x = element_text(angle = 0)), 
                          TA_DIC_Sal_re + facet_grid(~Zone)+
                              theme(legend.position = "none",
                                  strip.text.x = element_blank(),
                                  axis.text.x = element_text(angle = 0)), 
          #labels = c("A", "B"),
          ncol = 1, nrow = 3, heights = c(1, .9, .9))
Salinity_Region

#ggsave(file="FLK_results/Salinity_region.svg", plot=Salinity_Region, dpi = 300, width=5, height=4)

Figure 4. TA, DIC and TA/DIC linear regressions as a function of salinity. The vertical panels separate the locations by shelf zone. The black line and text on the top of each panel show the linear regression for all regions combined inside each zone. Additional colors differentiate the linear regressions by biogeographical region. Tables S7 and S8 shows the regression values per region and zone.

3.3 Salinity normalization

    1. Calculate TA intercepts

Note: Use Model II Linear regressions!

“For Model II regressions, neither X nor Y is an INDEPENDENT variable but both are assumed to be DEPENDENT on some other parameter which is often unknown. Neither are”controlled”, both are measured, and both include some error. We do not seek an equation of how Y varies in response to a change in X, but rather we look for how they both co-vary in time or space in response to some other variable or process.”

  • Use ordinary least squares (OLS)?

TA sal=0 intercept - all data

## 
## Model II regression
## 
## Call: lmodel2(formula = TA_umol_kg ~ BestSalinity, data = FLK.data)
## 
## n = 1528   r = -0.0798806   r-square = 0.006380911 
## Parametric P-values:   2-tailed = 0.001778394    1-tailed = 0.0008891968 
## Angle between the two OLS regression lines = 8.567075 degrees
## 
## Regression results
##   Method Intercept        Slope Angle (degrees) P-perm (1-tailed)
## 1    OLS  2602.395    -6.594665       -81.37749                NA
## 2     MA 39571.360 -1033.348355       -89.94455                NA
## 3    SMA  5337.454   -82.556525       -89.30602                NA
## 
## Confidence intervals
##   Method 2.5%-Intercept 97.5%-Intercept  2.5%-Slope 97.5%-Slope
## 1    OLS       2453.579        2751.212   -10.72682   -2.462508
## 2     MA      25238.802      102004.677 -2767.33354 -635.284556
## 3    SMA       5192.394        5489.956   -86.79203  -78.527716
## 
## Eigenvalues: 4192.065 0.611145 
## 
## H statistic used for computing C.I. of MA: 3.676832e-07

TA sal=0 intercept - Oceanic data

## 
## Model II regression
## 
## Call: lmodel2(formula = TA_umol_kg ~ BestSalinity, data =
## FLK.data[FLK.data$Zone == "Oceanic", ])
## 
## n = 197   r = 0.3700473   r-square = 0.136935 
## Parametric P-values:   2-tailed = 8.69786e-08    1-tailed = 4.34893e-08 
## Angle between the two OLS regression lines = 5.905429 degrees
## 
## Regression results
##   Method Intercept     Slope Angle (degrees) P-perm (1-tailed)
## 1    OLS 2081.9024  8.327531        83.15250                NA
## 2     MA  196.9878 60.710130        89.05633                NA
## 3    SMA 1571.7833 22.503963        87.45564                NA
## 
## Confidence intervals
##   Method 2.5%-Intercept 97.5%-Intercept 2.5%-Slope 97.5%-Slope
## 1    OLS       1975.640       2188.1646   5.374859    11.28020
## 2     MA      -1002.956        768.8619  44.817499    94.05708
## 3    SMA       1458.595       1671.0906  19.744169    25.64951
## 
## Eigenvalues: 178.7696 0.3044976 
## 
## H statistic used for computing C.I. of MA: 3.409103e-05

    1. Calculate DIC intercepts

DIC sal=0 intercept - All data

## 
## Model II regression
## 
## Call: lmodel2(formula = DIC_umol_kg ~ BestSalinity, data = FLK.data)
## 
## n = 1528   r = -0.2808293   r-square = 0.07886507 
## Parametric P-values:   2-tailed = 4.335416e-29    1-tailed = 2.167708e-29 
## Angle between the two OLS regression lines = 2.112403 degrees
## 
## Regression results
##   Method Intercept      Slope Angle (degrees) P-perm (1-tailed)
## 1    OLS  2936.374  -24.96993       -87.70663                NA
## 2     MA 13432.911 -316.57890       -89.81902                NA
## 3    SMA  5238.092  -88.91498       -89.35564                NA
## 
## Confidence intervals
##   Method 2.5%-Intercept 97.5%-Intercept 2.5%-Slope 97.5%-Slope
## 1    OLS       2782.096        3090.652  -29.25494   -20.68492
## 2     MA      11763.818       15793.523 -382.16010  -270.20908
## 3    SMA       5087.566        5396.046  -93.30318   -84.73316
## 
## Eigenvalues: 5037.321 0.5869003 
## 
## H statistic used for computing C.I. of MA: 2.938304e-07

DIC sal=0 - Oceanic data

## 
## Model II regression
## 
## Call: lmodel2(formula = DIC_umol_kg ~ BestSalinity, data =
## FLK.data[FLK.data$Zone == "Oceanic", ])
## 
## n = 197   r = 0.158424   r-square = 0.02509817 
## Parametric P-values:   2-tailed = 0.02618225    1-tailed = 0.01309113 
## Angle between the two OLS regression lines = 9.249221 degrees
## 
## Regression results
##   Method  Intercept      Slope Angle (degrees) P-perm (1-tailed)
## 1    OLS  1831.9262   5.982439        80.51041                NA
## 2     MA -6521.0089 238.198569        89.75946                NA
## 3    SMA   688.7919  37.762194        88.48308                NA
## 
## Confidence intervals
##   Method 2.5%-Intercept 97.5%-Intercept 2.5%-Slope 97.5%-Slope
## 1    OLS      1642.4827       2021.3698   0.716544    11.24833
## 2     MA    -69483.7639      -2509.8023 126.684850  1988.59733
## 3    SMA       486.2315        865.0655  32.861693    43.39348
## 
## Eigenvalues: 520.3287 0.3557205 
## 
## H statistic used for computing C.I. of MA: 1.365508e-05

    1. Add TA and DIC endmembers (S=0) to data frame (intercepts to salinity regressions)
    • This code uses the OLS intercepts calculated only with data from the oceanic zone
# Add endmember intercepts
  TA_SO<-subset(TA_coef_OLS, term=="(Intercept)")
  TA_SO<-as.data.frame(dplyr::select(TA_SO, c(Region, estimate)))
  names(TA_SO)[2] <- "TA_0"
  
  DIC_SO<-subset(DIC_coef_OLS, term=="(Intercept)")
  DIC_SO<-as.data.frame(dplyr::select(DIC_SO, c(Region, estimate)))
  names(DIC_SO)[2] <- "DIC_0"
    
  Intercepts<-join(TA_SO, DIC_SO, by="Region", type="full")
  FLK.data<-join(FLK.data, Intercepts, by="Region", type="left")
    1. Normalize with (1) Friss equation and (2) mean salinity
  # 1. endmember and salinity (mean) normalization (following Friiss)
  FLK.data$nTA<-((
    (FLK.data$TA_umol_kg-FLK.data$TA_0)/
    FLK.data$BestSalinity)*MeanSalinity)+FLK.data$TA_0
  
  FLK.data$nDIC<-((
    (FLK.data$DIC_umol_kg-FLK.data$DIC_0)/
    FLK.data$BestSalinity)*MeanSalinity)+FLK.data$DIC_0
  
  # 2. TA and DIC mean salinity normalization
    FLK.data$n36TA<-(FLK.data$TA_umol_kg/FLK.data$BestSalinity)*MeanSalinity
    FLK.data$n36DIC<-(FLK.data$DIC_umol_kg/FLK.data$BestSalinity)*MeanSalinity
    # FLK.data$n36TA<-(FLK.data$TA_umol_kg/FLK.data$BestSalinity)*35
    # FLK.data$n36DIC<-(FLK.data$DIC_umol_kg/FLK.data$BestSalinity)*35
  
#write.csv(FLK.data, "FLK_results/FLK.data_filtered_normalized.csv", row.names = F)
    1. Format the plots
# Plot 
Normalization_plot<- ggplot(FLK.data) +
  theme_bw() +  
  theme(legend.position="bottom",
          plot.background=element_blank(),
          panel.grid.major.y = element_blank(),
          panel.grid.major.x = element_blank(),
          panel.grid.minor.x = element_blank(),
          panel.grid.minor.y = element_blank(),
          legend.box.background = element_rect(),
          legend.title = element_blank(),
          panel.background =element_rect(fill = NA, 
                                         color = "black"))+
         scale_x_continuous(limits = c(31.5, 39),
                     expand = c(0.05, 0.05),
                     breaks = seq(30, 40, 2),
                     name=expression(paste("Salinity")))
    1. TA and DIC parameters (S=0)
#TA
kable(as.data.frame(TA_coef_OLS[,1:8], format = "markdown"), 
      caption = "Table: TA parameters for salinity normalization with endmember S=0",
      digits = 3)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table: TA parameters for salinity normalization with endmember S=0
Region term estimate std.error statistic p.value r.squared adj.r.squared
FL (Intercept) 2081.902 53.880 38.640 0 0.137 0.133
FL BestSalinity 8.328 1.497 5.562 0 0.137 0.133
#write.csv(TA_coef, "TA_coef.csv")

#DIC
kable(as.data.frame(DIC_coef_OLS[,1:8], format = "markdown"), 
      caption = "Table 2: DIC parameters for salinity normalization with endmember S0",
      digits = 2) %>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table 2: DIC parameters for salinity normalization with endmember S0
Region term estimate std.error statistic p.value r.squared adj.r.squared
FL (Intercept) 1831.93 96.06 19.07 0.00 0.03 0.02
FL BestSalinity 5.98 2.67 2.24 0.03 0.03 0.02
#write.csv(DIC_coef, "DIC_coef.csv")
    1. Make nTA by Friis and mean salinity plots
    1. Make nDIC by Friis and mean salinity plots

Figure S1: Overview of ordinary least squares (OLS) linear regressions of total alkalinity (TA, µmol kg−1) and dissolved inorganic carbon (DIC, µmol kg−1) as a function of salinity + Friss normalized values.

  • Original data: Black line and circles
  • Friis normalization S0 end-member: red line and pointing up triangles
  • Mean salinity normalization: red line and pointing down triangles

TA vs Friss salinity normalized TA

Figure Supp X: Linear regressions of Friss normalized total alkalinity (nTA, µmol kg−1) as a function of measured Total Alkalinity (TA, µmol kg−1)

DIC vs Friss salinity normalized DIC

Figure Supp X: Linear regressions of Friss normalized Dissolved Inorganic Carbon (nDIC, µmol kg−1) as a function of measured Dissolved Inorganic Carbon (DIC, µmol kg−1)

TA vs mean salinity normalized TA

Figure Supp X: Linear regressions of mean salinity normalized total alkalinity (n36TA, µmol kg−1) as a function of measured Total Alkalinity (TA, µmol kg−1)

DIC vs Salinity normalized DIC

Figure Supp X: Linear regressions of mean salinity normalized Dissolved Inorganic Carbon (n36DIC, µmol kg−1) as a function of measured Dissolved Inorganic Carbon (DIC, µmol kg−1)

Differences vs Salinity

Figure Supp X: Linear regressions of (A) TA-n36TA and (B) DIC-nDIC as a function of Salinity

4. Endmember comparissions (TA vs DIC)

  • Get data and plot formatting
FLK.data_filtered<-FLK.data[FLK.data$Extreme=="Normal",]
No_ocean.data<-FLK.data[FLK.data$Zone!="Oceanic",]
# Plot format
TA_DIC<- ggplot(No_ocean.data, aes (DIC_umol_kg, TA_umol_kg)) +
  scale_y_continuous(#limits = c(1700,2900),
                     #expand = c(0, 0),
                     #breaks = seq(1800, 2800, 100),
                     expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  scale_x_continuous(# limits = c(1600, 2600),
                     # expand = c(0, 0),
                     # breaks = seq(1500,2600,100),
                     expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
  facet_grid(Sub_region~Zone)+ MyTheme+ 
  theme(legend.position = "bottom")+
  #Season_fill+ Season_colour+
  guides(fill=guide_legend(override.aes=list(shape=21)))
TA_DIC_Zone <- ddply (FLK.data[FLK.data$Extreme=="Normal", ], .(Zone),summarise,
                TAmean = mean (TA_umol_kg, na.rm = T), 
                DICmean = mean (DIC_umol_kg, na.rm = T),
                nTAmean = mean (nTA, na.rm = T), 
                nDICmean = mean (nDIC, na.rm = T),
                n36TAmean = mean (n36TA, na.rm = T), 
                n36DICmean = mean (n36DIC, na.rm = T),
                TAsd = sd (TA_umol_kg, na.rm = T), 
                DICsd = sd (DIC_umol_kg, na.rm = T),
                nTAsd = sd (nTA, na.rm = T), 
                nDIsd = sd (nDIC, na.rm = T),
                n36TAsd = sd (n36TA, na.rm = T), 
                n36DIsd = sd (n36DIC, na.rm = T))

TA_DIC_Ocean<-TA_DIC_Zone[TA_DIC_Zone$Zone=="Oceanic", ]

kable(as.data.frame(TA_DIC_Zone, format = "markdown"),
      caption = "Mean TA and DIC values by zone") %>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Mean TA and DIC values by zone
Zone TAmean DICmean nTAmean nDICmean n36TAmean n36DICmean TAsd DICsd nTAsd nDIsd n36TAsd n36DIsd
Inshore 2340.787 2015.064 2340.866 2016.064 2333.990 2010.188 97.58327 110.70733 100.13778 113.28790 134.66366 147.79067
Mid channel 2364.723 2032.800 2364.064 2032.577 2359.007 2028.192 52.41657 58.19787 52.48511 58.87527 65.92103 74.37988
Offshore 2376.329 2043.844 2375.852 2043.482 2372.737 2040.658 19.67731 23.76709 19.58338 23.67911 37.86618 36.47511
Oceanic 2380.540 2044.319 2380.242 2044.073 2378.570 2042.690 11.82213 17.82925 11.20183 17.15285 34.44739 30.81862

Note: Use Model II Linear regressions!

“For Model II regressions, neither X nor Y is an INDEPENDENT variable but both are assumed to be DEPENDENT on some other parameter which is often unknown. Neither are”controlled”, both are measured, and both include some error. We do not seek an equation of how Y varies in response to a change in X, but rather we look for how they both co-vary in time or space in response to some other variable or process.”

4.1 TA vs DIC by zone and region

  • Using lm
# Individual LR for each Zone and Sub_region
TA_DIC_coef_zone_noExtremes <- No_ocean.data[No_ocean.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Sub_region) %>%
                    do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info

TA_DIC_coef_zone_noExtremes<-subset(TA_DIC_coef_zone_noExtremes, term!="(Intercept)")

kable(as.data.frame(TA_DIC_coef_zone_noExtremes[,1:8], 
      format = "markdown"),
      caption = "TA vs DIC equations by zone and region without extreme events",
      digits = 2)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
TA vs DIC equations by zone and region without extreme events
Zone Sub_region term estimate std.error statistic p.value r.squared
Inshore BB DIC_umol_kg 0.67 0.04 15.22 0 0.76
Inshore UK DIC_umol_kg 0.58 0.03 18.50 0 0.78
Inshore MK DIC_umol_kg 0.81 0.04 22.42 0 0.82
Inshore LK DIC_umol_kg 0.86 0.04 21.38 0 0.80
Mid channel BB DIC_umol_kg 0.57 0.06 9.71 0 0.58
Mid channel UK DIC_umol_kg 0.41 0.07 6.16 0 0.38
Mid channel MK DIC_umol_kg 0.83 0.04 21.55 0 0.81
Mid channel LK DIC_umol_kg 0.81 0.04 20.72 0 0.79
Offshore BB DIC_umol_kg 0.58 0.09 6.70 0 0.38
Offshore UK DIC_umol_kg 0.57 0.05 10.84 0 0.55
Offshore MK DIC_umol_kg 0.77 0.04 19.96 0 0.78
Offshore LK DIC_umol_kg 0.57 0.04 13.61 0 0.56
#write.csv(TA_DIC_coef_zone_noExtremes, "FLK_results/Fig_2_TA_DIC_coef_slopes_Subregion.csv", row.names = FALSE)

# Annotations for plots
  coef_zone_noExtremes<-dplyr::select(TA_DIC_coef_zone_noExtremes, 
                               c("Zone", "Sub_region", "estimate", "r.squared"))
  coef_zone_noExtremes$estimate<-round(coef_zone_noExtremes$estimate, digits=2)
  coef_zone_noExtremes$r.squared<-round(coef_zone_noExtremes$r.squared, digits=2)
  • Using lmodel2
TA_DIC_coef_zone_noExtII <- No_ocean.data[No_ocean.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Sub_region) %>%
                    do({model = lmodel2(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
#TA_DIC_coef_zone_noExtII

TA_DIC_coef_zone_noExtII<-subset(TA_DIC_coef_zone_noExtII, term!="Intercept")
kable(as.data.frame(TA_DIC_coef_zone_noExtII[,1:9], 
      format = "markdown"),
      caption = "TA vs DIC equations without extreme events using type II lm",
      digits = 2)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
TA vs DIC equations without extreme events using type II lm
Zone Sub_region method term estimate conf.low conf.high p.value r.squared
Inshore BB MA Slope 0.74 0.64 0.84 0.76
Inshore BB OLS Slope 0.67 0.58 0.76 0.76
Inshore BB SMA Slope 0.77 0.68 0.86 0.76
Inshore UK MA Slope 0.62 0.56 0.69 0.78
Inshore UK OLS Slope 0.58 0.52 0.64 0.78
Inshore UK SMA Slope 0.66 0.60 0.72 0.78
Inshore MK MA Slope 0.89 0.81 0.97 0.82
Inshore MK OLS Slope 0.81 0.74 0.88 0.82
Inshore MK SMA Slope 0.90 0.83 0.97 0.82
Inshore LK MA Slope 0.96 0.87 1.05 0.80
Inshore LK OLS Slope 0.86 0.78 0.94 0.80
Inshore LK SMA Slope 0.96 0.89 1.05 0.80
Mid channel BB MA Slope 0.69 0.55 0.84 0.58
Mid channel BB OLS Slope 0.57 0.45 0.69 0.58
Mid channel BB SMA Slope 0.75 0.64 0.87 0.58
Mid channel UK MA Slope 0.54 0.37 0.73 0.38
Mid channel UK OLS Slope 0.41 0.28 0.55 0.38
Mid channel UK SMA Slope 0.67 0.55 0.82 0.38
Mid channel MK MA Slope 0.91 0.83 1.00 0.81
Mid channel MK OLS Slope 0.83 0.75 0.90 0.81
Mid channel MK SMA Slope 0.92 0.85 1.00 0.81
Mid channel LK MA Slope 0.90 0.82 0.99 0.79
Mid channel LK OLS Slope 0.81 0.73 0.88 0.79
Mid channel LK SMA Slope 0.91 0.84 0.99 0.79
Offshore BB MA Slope 0.89 0.65 1.20 0.38
Offshore BB OLS Slope 0.58 0.40 0.75 0.38
Offshore BB SMA Slope 0.93 0.77 1.12 0.38
Offshore UK MA Slope 0.70 0.58 0.84 0.55
Offshore UK OLS Slope 0.57 0.47 0.67 0.55
Offshore UK SMA Slope 0.77 0.67 0.88 0.55
Offshore MK MA Slope 0.86 0.78 0.95 0.78
Offshore MK OLS Slope 0.77 0.70 0.85 0.78
Offshore MK SMA Slope 0.87 0.80 0.95 0.78
Offshore LK MA Slope 0.70 0.60 0.80 0.56
Offshore LK OLS Slope 0.57 0.49 0.65 0.56
Offshore LK SMA Slope 0.76 0.68 0.85 0.56
# Annotations for plots
  TA_DIC_coef_zone_noExtII<-dplyr::select(TA_DIC_coef_zone_noExtII, 
                               c("Zone", "Sub_region","method", "estimate", "r.squared"))
  TA_DIC_coef_zone_noExtII$estimate<-round(TA_DIC_coef_zone_noExtII$estimate, digits=2)
  TA_DIC_coef_zone_noExtII$r.squared<-round(TA_DIC_coef_zone_noExtII$r.squared, digits=2)

4.2 TA vs DIC by Precipitation season - Removing Extreme events

TA_DIC_Extreme_pre<-TA_DIC + 
  geom_abline(intercept = -1700, slope=2, color="grey")+
  geom_hline (yintercept = TA_DIC_Ocean$TAmean, color="grey")+
  scale_shape_manual(values=c(24, 25, 23, 22, 21))+
  geom_point(data=No_ocean.data, aes (DIC_umol_kg, TA_umol_kg,
                                 fill=Precipitation, shape=Extreme),
                            alpha=0.5, size=1)+
  geom_smooth(data=No_ocean.data[No_ocean.data$Extreme=="Normal", ], 
              aes(DIC_umol_kg, TA_umol_kg), 
              method = "lm", colour="black", se=F)+
  
   geom_smooth(data=No_ocean.data[No_ocean.data$Extreme=="Normal", ], 
              aes(DIC_umol_kg, TA_umol_kg, colour=Precipitation), 
              method = "lm", se=F, size=0.5)+
  
  geom_text(data = coef_zone_noExtremes, 
            aes(x = TA_DIC_Ocean$DICmean, y = 2070,
                label = paste("Slo =", estimate,  
                              " r.sq=", r.squared)),
            size=2.5)+
  
  # geom_abline(slope = 0, intercept =TA_DIC_Ocean$TAmean, 
  #           linetype=2, colour="gray")+
  # geom_vline(xintercept = TA_DIC_Ocean$DICmean,
  #          linetype=2, colour="gray")+
  geom_point(aes(x=TA_DIC_Ocean$DICmean, y=TA_DIC_Ocean$TAmean),
             size=3, alpha=1, shape=21, fill="black")
#TA_DIC_Extreme_pre

Zone, region and transect

# Individual LR for each reef
TA_DIC_coef_Reef_noExtremes <- No_ocean.data[No_ocean.data$Extreme=="Normal", ] %>% 
            group_by(Zone, Sub_region, Reference, Precipitation) %>%
            do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
            data.frame(tidy(model), # get coefficient info
            glance(model))})        # get model info

TA_DIC_coef_Reef_noExtremes<-subset(TA_DIC_coef_Reef_noExtremes, term!="(Intercept)")
kable(as.data.frame(TA_DIC_coef_Reef_noExtremes[,1:11],
                      format = "markdown"),
        caption = "TA vs DIC equations by reef without extreme events per trsansec",
        digits = 2)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
TA vs DIC equations by reef without extreme events per trsansec
Zone Sub_region Reference Precipitation term estimate std.error statistic p.value r.squared adj.r.squared
Inshore BB BB_1 Dry DIC_umol_kg 0.58 0.05 10.57 0.00 0.85 0.85
Inshore BB BB_1 Wet DIC_umol_kg 0.72 0.07 10.43 0.00 0.86 0.86
Inshore BB BB_2 Dry DIC_umol_kg 0.54 0.07 7.89 0.00 0.79 0.77
Inshore BB BB_2 Wet DIC_umol_kg 0.47 0.15 3.15 0.01 0.42 0.37
Inshore UK UK_3 Dry DIC_umol_kg 0.58 0.03 18.79 0.00 0.92 0.91
Inshore UK UK_3 Wet DIC_umol_kg 0.47 0.09 5.16 0.00 0.50 0.48
Inshore UK UK_4 Dry DIC_umol_kg 0.54 0.05 11.46 0.00 0.90 0.89
Inshore UK UK_4 Wet DIC_umol_kg 0.35 0.22 1.59 0.13 0.15 0.09
Inshore MK MK_5 Dry DIC_umol_kg 0.56 0.06 8.81 0.00 0.82 0.81
Inshore MK MK_5 Wet DIC_umol_kg 0.70 0.11 6.19 0.00 0.71 0.69
Inshore MK MK_6 Dry DIC_umol_kg 0.72 0.09 8.38 0.00 0.81 0.80
Inshore MK MK_6 Wet DIC_umol_kg 0.80 0.13 6.25 0.00 0.70 0.68
Inshore MK MK_7 Dry DIC_umol_kg 0.67 0.08 8.84 0.00 0.84 0.83
Inshore MK MK_7 Wet DIC_umol_kg 0.93 0.15 6.18 0.00 0.69 0.67
Inshore LK LK_8 Dry DIC_umol_kg 0.79 0.10 8.00 0.00 0.78 0.77
Inshore LK LK_8 Wet DIC_umol_kg 0.80 0.11 7.18 0.00 0.76 0.75
Inshore LK LK_9 Dry DIC_umol_kg 0.68 0.09 7.62 0.00 0.77 0.76
Inshore LK LK_9 Wet DIC_umol_kg 0.70 0.19 3.76 0.00 0.47 0.44
Inshore LK LK_10 Dry DIC_umol_kg 0.84 0.14 5.87 0.00 0.63 0.61
Inshore LK LK_10 Wet DIC_umol_kg 0.64 0.14 4.74 0.00 0.57 0.54
Mid channel BB BB_1 Dry DIC_umol_kg 0.53 0.08 6.67 0.00 0.72 0.71
Mid channel BB BB_1 Wet DIC_umol_kg 0.60 0.14 4.36 0.00 0.56 0.53
Mid channel BB BB_2 Dry DIC_umol_kg 0.52 0.09 5.54 0.00 0.66 0.64
Mid channel BB BB_2 Wet DIC_umol_kg 0.38 0.29 1.30 0.22 0.12 0.05
Mid channel UK UK_3 Dry DIC_umol_kg 0.36 0.14 2.58 0.02 0.36 0.30
Mid channel UK UK_3 Wet DIC_umol_kg 0.00 0.17 -0.02 0.98 0.00 -0.07
Mid channel UK UK_4 Dry DIC_umol_kg 0.49 0.10 4.77 0.00 0.60 0.58
Mid channel UK UK_4 Wet DIC_umol_kg 0.63 0.25 2.57 0.02 0.32 0.27
Mid channel MK MK_5 Dry DIC_umol_kg 0.47 0.10 4.53 0.00 0.53 0.51
Mid channel MK MK_5 Wet DIC_umol_kg 0.88 0.17 5.18 0.00 0.61 0.59
Mid channel MK MK_6 Dry DIC_umol_kg 0.59 0.09 6.35 0.00 0.70 0.69
Mid channel MK MK_6 Wet DIC_umol_kg 0.83 0.10 8.45 0.00 0.82 0.81
Mid channel MK MK_7 Dry DIC_umol_kg 0.63 0.07 8.50 0.00 0.82 0.81
Mid channel MK MK_7 Wet DIC_umol_kg 1.09 0.12 9.25 0.00 0.84 0.83
Mid channel LK LK_8 Dry DIC_umol_kg 0.56 0.16 3.50 0.00 0.39 0.36
Mid channel LK LK_8 Wet DIC_umol_kg 0.96 0.07 14.05 0.00 0.92 0.92
Mid channel LK LK_9 Dry DIC_umol_kg 0.67 0.10 6.51 0.00 0.70 0.69
Mid channel LK LK_9 Wet DIC_umol_kg 0.92 0.12 7.51 0.00 0.77 0.75
Mid channel LK LK_10 Dry DIC_umol_kg 0.42 0.18 2.37 0.03 0.22 0.18
Mid channel LK LK_10 Wet DIC_umol_kg 0.88 0.13 6.51 0.00 0.73 0.71
Offshore BB BB_1 Dry DIC_umol_kg 0.53 0.11 4.70 0.00 0.54 0.51
Offshore BB BB_1 Wet DIC_umol_kg 0.61 0.22 2.82 0.01 0.32 0.28
Offshore BB BB_2 Dry DIC_umol_kg 0.49 0.15 3.28 0.00 0.40 0.37
Offshore BB BB_2 Wet DIC_umol_kg 0.57 0.31 1.82 0.09 0.19 0.13
Offshore UK UK_3 Dry DIC_umol_kg 0.63 0.10 6.55 0.00 0.60 0.58
Offshore UK UK_3 Wet DIC_umol_kg 0.56 0.15 3.82 0.00 0.32 0.30
Offshore UK UK_4 Dry DIC_umol_kg 0.48 0.09 5.19 0.00 0.63 0.60
Offshore UK UK_4 Wet DIC_umol_kg 0.90 0.13 6.90 0.00 0.77 0.76
Offshore MK MK_5 Dry DIC_umol_kg 0.50 0.10 5.09 0.00 0.59 0.57
Offshore MK MK_5 Wet DIC_umol_kg 0.85 0.07 12.02 0.00 0.89 0.89
Offshore MK MK_6 Dry DIC_umol_kg 0.51 0.10 4.89 0.00 0.56 0.53
Offshore MK MK_6 Wet DIC_umol_kg 1.07 0.11 9.62 0.00 0.86 0.85
Offshore MK MK_7 Dry DIC_umol_kg 0.43 0.09 4.67 0.00 0.58 0.55
Offshore MK MK_7 Wet DIC_umol_kg 0.95 0.10 9.22 0.00 0.84 0.83
Offshore LK LK_8 Dry DIC_umol_kg 0.25 0.08 3.09 0.01 0.35 0.31
Offshore LK LK_8 Wet DIC_umol_kg 0.97 0.11 8.46 0.00 0.80 0.79
Offshore LK LK_9 Dry DIC_umol_kg 0.55 0.09 6.41 0.00 0.73 0.71
Offshore LK LK_9 Wet DIC_umol_kg 0.83 0.12 6.98 0.00 0.75 0.74
Offshore LK LK_10 Dry DIC_umol_kg 0.48 0.10 4.91 0.00 0.41 0.40
Offshore LK LK_10 Wet DIC_umol_kg 0.77 0.13 5.72 0.00 0.50 0.48
#write.csv (TA_DIC_coef_Reef_noExtremes, "FLK_results/Fig_2_TA_DIC_slopes_Reefs.csv", row.names = FALSE)
  
  
TA_DIC_coef_Reef_noExtremes <- 
  No_ocean.data[No_ocean.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Region, Sub_region, Transect, Precipitation) %>%
                    do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
TA_DIC_reef_pre<-TA_DIC_Extreme_pre + 
  facet_grid(Zone~Reference)
#TA_DIC_reef_pre
Slopes_reef<-subset(TA_DIC_coef_Reef_noExtremes, term!="(Intercept)")

Slope_plot<-ggplot(data=Slopes_reef, aes (x =Zone, y =estimate)) +
  MyTheme+
  scale_shape_manual(values=c(24, 25, 23, 22, 21))+
  geom_boxplot(aes(fill=(Precipitation)), alpha=0.5,
               position=position_dodge(width=0.3))+
  geom_point(aes(fill = factor(Precipitation)), 
              position=position_dodge(width=0.3),
             shape = 21, size=0.5)+
  scale_y_continuous(#limits = c(1700,2900),
                     #expand = c(0, 0),
                     #breaks = seq(1800, 2800, 100),
                     expression(paste("TA vs DIC slope")))+
  theme(axis.text.x = element_text(angle = 0, vjust = 0.1),
        legend.position = "bottom")+
  #guides(fill=FALSE)+
  facet_grid(Sub_region~Region)
  # Season_fill+ Season_colour+
  # theme(legend.title = element_blank())
#Slope_plot

Pot zone and region (precipitation) and add the individual slopes by transect in panel b

Figure S9: TA (µmol kg−1) vs DIC (µmol kg−1) slopes per season and reef

4.3 By Season - Removing Extreme events

TA_DIC_season<-TA_DIC + 
  Season_colour+ Season_fill+
  geom_abline(intercept = -1700, slope=2, color="grey")+
  geom_hline (yintercept = TA_DIC_Ocean$TAmean, color="grey")+
  scale_shape_manual(values=c(24, 25, 23, 22, 21))+
  geom_point(data=No_ocean.data, aes (DIC_umol_kg, TA_umol_kg,
                                 fill=Season, shape=Extreme),
                            alpha=0.5, size=1)+
  geom_smooth(data=No_ocean.data[No_ocean.data$Extreme=="Normal", ], 
              aes(DIC_umol_kg, TA_umol_kg), 
              method = "lm", colour="black", se=F)+
  
   geom_smooth(data=No_ocean.data[No_ocean.data$Extreme=="Normal", ], 
              aes(DIC_umol_kg, TA_umol_kg, colour=Season), 
              method = "lm", se=F, size=0.5)+
  
  geom_text(data = coef_zone_noExtremes, 
            aes(x = TA_DIC_Ocean$DICmean, y = 2070,
                label = paste("Slo =", estimate,  
                              " r.sq=", r.squared)),
            size=2.5)+

  geom_point(aes(x=TA_DIC_Ocean$DICmean, y=TA_DIC_Ocean$TAmean),
             size=3, alpha=1, shape=21, fill="black")
#TA_DIC_season
# Individual LR for each reef
TA_DIC_coef_Season_noExtremes <- FLK.data[FLK.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Sub_region, Season) %>%
                    do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info

TA_DIC_coef_Season_noExtremes<-subset(TA_DIC_coef_Season_noExtremes, term!="(Intercept)")
kable(as.data.frame(TA_DIC_coef_Season_noExtremes[,1:11],
                      format = "markdown"),
        caption = "TA vs DIC equations by season without extreme events",
        digits = 2)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
TA vs DIC equations by season without extreme events
Zone Sub_region Season term estimate std.error statistic p.value r.squared adj.r.squared sigma
Inshore BB Winter DIC_umol_kg 0.67 0.10 6.59 0.00 0.74 0.73 23.70
Inshore BB Spring DIC_umol_kg 0.86 0.11 7.52 0.00 0.75 0.74 36.03
Inshore BB Summer DIC_umol_kg 0.54 0.15 3.61 0.00 0.48 0.45 37.42
Inshore BB Fall DIC_umol_kg 0.80 0.09 8.72 0.00 0.80 0.79 22.56
Inshore UK Winter DIC_umol_kg 0.71 0.05 13.83 0.00 0.91 0.90 21.12
Inshore UK Spring DIC_umol_kg 0.58 0.06 8.96 0.00 0.76 0.75 22.93
Inshore UK Summer DIC_umol_kg 0.80 0.27 2.92 0.01 0.28 0.25 42.64
Inshore UK Fall DIC_umol_kg 0.72 0.06 11.23 0.00 0.85 0.84 27.46
Inshore MK Winter DIC_umol_kg 0.84 0.08 10.16 0.00 0.84 0.83 34.06
Inshore MK Spring DIC_umol_kg 0.84 0.10 8.32 0.00 0.68 0.67 41.83
Inshore MK Summer DIC_umol_kg 1.08 0.10 11.08 0.00 0.85 0.85 37.41
Inshore MK Fall DIC_umol_kg 0.82 0.07 11.50 0.00 0.83 0.82 27.51
Inshore LK Winter DIC_umol_kg 0.64 0.12 5.22 0.00 0.51 0.49 44.09
Inshore LK Spring DIC_umol_kg 0.87 0.08 10.52 0.00 0.77 0.76 35.49
Inshore LK Summer DIC_umol_kg 0.90 0.12 7.58 0.00 0.76 0.75 39.84
Inshore LK Fall DIC_umol_kg 1.08 0.06 17.96 0.00 0.91 0.91 25.26
Mid channel BB Winter DIC_umol_kg 0.80 0.12 6.54 0.00 0.75 0.74 9.85
Mid channel BB Spring DIC_umol_kg 0.64 0.08 7.88 0.00 0.80 0.78 11.95
Mid channel BB Summer DIC_umol_kg 0.61 0.36 1.71 0.11 0.17 0.11 21.37
Mid channel BB Fall DIC_umol_kg 0.56 0.11 5.32 0.00 0.63 0.60 11.63
Mid channel UK Winter DIC_umol_kg 0.66 0.09 7.62 0.00 0.82 0.80 13.29
Mid channel UK Spring DIC_umol_kg 0.01 0.13 0.04 0.97 0.00 -0.07 13.59
Mid channel UK Summer DIC_umol_kg 1.09 0.32 3.45 0.00 0.50 0.46 17.14
Mid channel UK Fall DIC_umol_kg 0.57 0.13 4.44 0.00 0.57 0.54 14.12
Mid channel MK Winter DIC_umol_kg 0.72 0.07 10.08 0.00 0.82 0.81 21.50
Mid channel MK Spring DIC_umol_kg 0.97 0.08 11.47 0.00 0.81 0.80 29.81
Mid channel MK Summer DIC_umol_kg 1.25 0.10 12.61 0.00 0.88 0.87 21.92
Mid channel MK Fall DIC_umol_kg 0.63 0.06 10.51 0.00 0.80 0.79 14.44
Mid channel LK Winter DIC_umol_kg 0.73 0.14 5.10 0.00 0.48 0.46 35.75
Mid channel LK Spring DIC_umol_kg 0.74 0.08 9.40 0.00 0.73 0.73 27.01
Mid channel LK Summer DIC_umol_kg 0.97 0.06 15.11 0.00 0.92 0.92 18.73
Mid channel LK Fall DIC_umol_kg 0.82 0.16 4.96 0.00 0.44 0.42 19.50
Offshore BB Winter DIC_umol_kg 0.74 0.12 5.98 0.00 0.70 0.68 8.49
Offshore BB Spring DIC_umol_kg 0.48 0.13 3.63 0.00 0.41 0.38 8.38
Offshore BB Summer DIC_umol_kg 0.84 0.37 2.27 0.04 0.27 0.22 21.24
Offshore BB Fall DIC_umol_kg 0.32 0.11 2.93 0.01 0.32 0.29 8.97
Offshore UK Winter DIC_umol_kg 0.63 0.08 8.01 0.00 0.75 0.74 6.58
Offshore UK Spring DIC_umol_kg 0.48 0.17 2.86 0.01 0.25 0.22 10.70
Offshore UK Summer DIC_umol_kg 0.93 0.14 6.78 0.00 0.70 0.68 9.77
Offshore UK Fall DIC_umol_kg 0.48 0.11 4.36 0.00 0.44 0.42 10.84
Offshore MK Winter DIC_umol_kg 0.62 0.09 6.95 0.00 0.68 0.66 8.56
Offshore MK Spring DIC_umol_kg 0.89 0.07 12.65 0.00 0.84 0.83 13.80
Offshore MK Summer DIC_umol_kg 0.99 0.08 11.80 0.00 0.86 0.86 12.32
Offshore MK Fall DIC_umol_kg 0.43 0.09 5.03 0.00 0.47 0.45 9.97
Offshore LK Winter DIC_umol_kg 0.48 0.09 5.28 0.00 0.47 0.45 10.09
Offshore LK Spring DIC_umol_kg 0.61 0.08 7.90 0.00 0.61 0.60 11.79
Offshore LK Summer DIC_umol_kg 0.89 0.14 6.41 0.00 0.60 0.59 12.52
Offshore LK Fall DIC_umol_kg 0.30 0.08 3.52 0.00 0.24 0.22 7.99
Oceanic UK Winter DIC_umol_kg 0.74 0.10 7.49 0.00 0.90 0.89 4.81
Oceanic UK Spring DIC_umol_kg 0.17 0.21 0.82 0.44 0.09 -0.04 5.84
Oceanic UK Summer DIC_umol_kg 0.86 0.31 2.79 0.05 0.66 0.58 11.68
Oceanic UK Fall DIC_umol_kg 0.33 0.22 1.51 0.18 0.28 0.16 10.94
Oceanic MK Winter DIC_umol_kg 0.58 0.07 8.35 0.00 0.83 0.82 5.13
Oceanic MK Spring DIC_umol_kg 0.45 0.12 3.77 0.00 0.47 0.44 8.16
Oceanic MK Summer DIC_umol_kg 0.79 0.11 7.49 0.00 0.80 0.79 6.42
Oceanic MK Fall DIC_umol_kg 0.32 0.12 2.60 0.02 0.27 0.23 10.20
Oceanic LK Winter DIC_umol_kg 0.45 0.15 3.02 0.01 0.35 0.31 11.24
Oceanic LK Spring DIC_umol_kg 0.51 0.11 4.73 0.00 0.53 0.50 8.38
Oceanic LK Summer DIC_umol_kg 0.66 0.13 4.94 0.00 0.69 0.66 7.63
Oceanic LK Fall DIC_umol_kg 0.27 0.12 2.18 0.04 0.22 0.17 7.33
#write.csv (TA_DIC_coef_Season_noExtremes, "FLK_results/Fig_5_TA_DIC_slopes_Reefs.csv", row.names = FALSE)
  
  
TA_DIC_coef_Season_noExtremes <- FLK.data[FLK.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Region, Sub_region, Season, Transect) %>%
                    do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
Slopes_season<-subset(TA_DIC_coef_Season_noExtremes, term!="(Intercept)")

Slope_plot<-ggplot(data=Slopes_season, aes (x =Zone, y =estimate)) +
  MyTheme+
  Zone_shapes4+
  geom_boxplot(aes(fill=Season), alpha=0.5,
               position=position_dodge(width=0.3))+
  geom_point(aes(fill = factor(Season)), 
              position=position_dodge(width=0.3),
             shape = 21, size=0.5)+
  scale_y_continuous(#limits = c(1700,2900),
                     #expand = c(0, 0),
                     #breaks = seq(1800, 2800, 100),
                     expression(paste("TA vs DIC slope")))+
  facet_grid(Sub_region~Region)+
  Season_fill+
  Season_colour+
  guides(fill=FALSE)+
  theme(axis.text.x = element_text(angle = 90, vjust = 0.1),
        legend.position = "bottom")
#Slope_plot

Figure 6: TA (µmol kg−1) vs DIC (µmol kg−1) slopes per season and reef

5 Seasonal plots

Data for endmember comparisons

# Reef
  WS.reef<-subset(FLK.data, FLK.data$Zone!="Oceanic")
  WS.reef$Date<-as.Date(WS.reef$Date, "%Y-%m-%d")
  
# Open
  WS.open<-subset(FLK.data_filtered,
                  FLK.data_filtered$Zone=="Oceanic")
  WS.open$Date<-as.Date(WS.open$Date, "%Y-%m-%d")
  #summary(WS.open)
# Mean ocean values by month - year 
  mean_Open_MY<- ddply (WS.open, .(MY, Month),
                            summarise,
                  OTem_my = mean (Temperature_C, na.rm = T),  
                  OSal_my = mean (BestSalinity, na.rm = T), 
                  
                  OTA_my = mean (TA_umol_kg, na.rm = T),
                  OnTA_my = mean (n36TA, na.rm = T),
                  
                  ODIC_my = mean (DIC_umol_kg, na.rm = T),
                  OnDIC_my = mean (n36DIC, na.rm = T),
                  
                  OpCO2_O = mean (pCO2_uatm , na.rm = T),
                  OpH_O = mean (pH_calculated, na.rm = T),
                  OAra_O = mean (Aragonite_Sat_W , na.rm = T)
                  )

# Mean ocean values by month
  mean_OpM <- mean_Open_MY %>%
              group_by(Month) %>%
              summarise(
                  OTem_m = mean (OTem_my, na.rm = T), 
                  OSal_m = mean (OSal_my, na.rm = T), 
                  
                  OTA_m = mean (OTA_my, na.rm = T),
                  OnTA_m = mean (OnTA_my, na.rm = T),
                  
                  OnDIC_m = mean (OnDIC_my, na.rm = T),
                  ODIC_m = mean (ODIC_my, na.rm = T),
                  
                  OpCO2_m = mean (OpCO2_O , na.rm = T),
                  OpH_m = mean (OpH_O, na.rm = T),
                  OAra_m = mean (OAra_O, na.rm = T),
                  n = n()
                  )
   #mean_OpM
  
 # Mean ocean values by year    
  mean_Op<- mean_OpM %>%
            summarise(
                  OTem = mean (OTem_m, na.rm = T), 
                  OSal  = mean (OSal_m, na.rm = T), 
                  
                  OTA = mean (OTA_m, na.rm = T),
                  OnTA = mean (OnTA_m, na.rm = T),
                  
                  OnDIC = mean (OnDIC_m, na.rm = T),
                  ODIC = mean (ODIC_m, na.rm = T),
                  
                  OpCO2 = mean (OpCO2_m, na.rm = T),
                  OpH = mean (OpH_m, na.rm = T),
                  OAra = mean (OAra_m, na.rm = T),
                  n = n()
                  )

5.1 Month raw values

- Months stats

Month_Stats<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region),
                            summarise,
                       
                  Tem_mean = mean (Temperature_C, na.rm = T),
                  Tem_sd = sd (Temperature_C, na.rm = T),
                  #Tem_se = std.error (Temperature_C, na.rm = T),
                  
                  Sal_mean = mean (BestSalinity, na.rm = T),
                  Sal_sd = sd (BestSalinity, na.rm = T),
                  #Sal_se = std.error (BestSalinity, na.rm = T),
                       
                  TA_mean = mean (TA_umol_kg, na.rm = T),
                  TA_sd = sd (TA_umol_kg, na.rm = T),
                  #TA_se = std.error (TA_umol_kg, na.rm = T),
                  
                  nTA_mean = mean (n36TA, na.rm = T),
                  nTA_sd = sd (n36TA, na.rm = T),
                  
                  DIC_mean = mean (DIC_umol_kg, na.rm = T),
                  DIC_sd = sd (DIC_umol_kg, na.rm = T),
                  #DIC_se = std.error (DIC_umol_kg, na.rm = T),
                  
                  nDIC_mean = mean (n36DIC, na.rm = T),
                  nDIC_sd = sd (n36DIC, na.rm = T),
                  
                  pCO2_mean = mean (pCO2_uatm , na.rm = T),
                  pCO2_sd = sd (pCO2_uatm , na.rm = T),
                  #pCO2_se = std.error (pCO2_uatm, na.rm = T),
                  
                  pH_mean = mean (pH_calculated, na.rm = T),
                  pH_sd = sd (pH_calculated, na.rm = T),
                  #pH_se = std.error (pH_calculated, na.rm = T),
                  
                  Ara_mean = mean (Aragonite_Sat_W , na.rm = T),
                  Ara_sd = sd (Aragonite_Sat_W , na.rm = T),
                  #Ara_se = std.error (Aragonite_Sat_W, na.rm = T),
                  n = n())

Month_Stats_2d<-Month_Stats %>% 
 mutate_if(is.numeric, round, digits=3)
Month_Stats_2d
#write.csv(Month_Stats, "FLK_results/Table_S7_Month_Stats.csv", row.names = F)

Temp

Month_Temp<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (Temperature_C, na.rm = T),
                  sd = sd (Temperature_C, na.rm = T))

Month_Temp<-Month_Temp %>% 
 mutate_if(is.numeric, round, digits=2)
Month_Temp$Region<-NULL

Month_Temp<-reshape(Month_Temp, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

Sal

Month_Sal<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (BestSalinity, na.rm = T),
                  sd = sd (BestSalinity, na.rm = T))

Month_Sal<-Month_Sal %>% 
 mutate_if(is.numeric, round, digits=2)
Month_Sal$Region<-NULL

Month_Sal<-reshape(Month_Sal, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

TA

Month_TA<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (TA_umol_kg, na.rm = T),
                  sd = sd (TA_umol_kg, na.rm = T))

Month_TA<-Month_TA %>% 
 mutate_if(is.numeric, round, digits=2)
Month_TA$Region<-NULL

Month_TA<-reshape(Month_TA, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

DIC

Month_DIC<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (DIC_umol_kg, na.rm = T),
                  sd = sd (DIC_umol_kg, na.rm = T))

Month_DIC<-Month_DIC %>% 
 mutate_if(is.numeric, round, digits=2)
Month_DIC$Region<-NULL

Month_DIC<-reshape(Month_DIC, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

pCO2

Month_pCO2<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (pCO2_uatm , na.rm = T),
                  sd = sd (pCO2_uatm , na.rm = T))

Month_pCO2<-Month_pCO2 %>% 
 mutate_if(is.numeric, round, digits=2)
Month_pCO2$Region<-NULL

Month_pCO2<-reshape(Month_pCO2, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

pH

Month_pH<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (pH_calculated, na.rm = T),
                  sd = sd (pH_calculated, na.rm = T))

Month_pH<-Month_pH %>% 
 mutate_if(is.numeric, round, digits=2)
Month_pH$Region<-NULL

Month_pH<-reshape(Month_pH, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

Arag

Month_Ara<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (Aragonite_Sat_W , na.rm = T),
                  sd = sd (Aragonite_Sat_W , na.rm = T))

Month_Ara<-Month_Ara %>% 
 mutate_if(is.numeric, round, digits=2)
Month_Ara$Region<-NULL

Month_Ara<-reshape(Month_Ara, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

all

Month_Stats3<-rbind(Month_Temp, Month_Sal, Month_TA, Month_DIC, 
      Month_pCO2, Month_pH, Month_Ara)

#write.csv(Month_Stats3, "FLK_results/Table_S7_Month_Stats_wide.csv", row.names = F)

Seasonal range

Seasonal_range<-ddply (Month_Stats, .(Zone, Sub_region),
                            summarise,
                  Tem_meany = mean (Tem_mean, na.rm = T),
                  Tem_sdy = sd (Tem_mean, na.rm = T),
                  Tem_max = max (Tem_mean, na.rm = T),
                  Tem_min = min (Tem_mean, na.rm = T),
                  Tem_diff = (max (Tem_mean, na.rm = T) - min (Tem_mean, na.rm = T)),
                  
                  Sal_meany = mean (Sal_mean, na.rm = T),
                  Sal_sdy = sd (Sal_mean, na.rm = T),
                  Sal_max = max (Sal_mean, na.rm = T),
                  Sal_min = min (Sal_mean, na.rm = T),
                  Sal_diff = (max (Sal_mean, na.rm = T) - min (Sal_mean, na.rm = T)),
                  
                  TA_meany = mean (TA_mean, na.rm = T),
                  TA_sdy = sd (TA_mean, na.rm = T), 
                  TA_max = max (TA_mean, na.rm = T),
                  TA_min = min (TA_mean, na.rm = T),
                  TA_diff = (max (TA_mean, na.rm = T) - min (TA_mean, na.rm = T)),
                  
                  DIC_meany = mean (DIC_mean, na.rm = T),
                  DIC_sdy = sd (DIC_mean, na.rm = T), 
                  DIC_max = max (DIC_mean, na.rm = T),
                  DIC_min = min (DIC_mean, na.rm = T),
                  DIC_diff = (max (DIC_mean, na.rm = T) - min (DIC_mean, na.rm = T)),
                  
                  pCO2_meany = mean (pCO2_mean, na.rm = T),
                  pCO2_sdy = sd (pCO2_mean, na.rm = T), 
                  pCO2_max = max (pCO2_mean, na.rm = T),
                  pCO2_min = min (pCO2_mean, na.rm = T),
                  pCO2_dif = (max (pCO2_mean, na.rm = T) - min (pCO2_mean, na.rm = T)),
                  
                  pH_meany = mean (pH_mean, na.rm = T),
                  pH_sdy = sd (pH_mean, na.rm = T), 
                  pH_max = max (pH_mean, na.rm = T),
                  pH_min = min (pH_mean, na.rm = T),
                  pH_diff = (max (pH_mean, na.rm = T) - min (pH_mean, na.rm = T)),
                  
                  Arg_meany = mean (Ara_mean, na.rm = T),
                  Arg_sdy = sd (Ara_mean, na.rm = T),  
                  Ara_max = max (Ara_mean, na.rm = T),
                  Ara_min = min (Ara_mean, na.rm = T),
                  Ara_diff = (max (Ara_mean, na.rm = T) - min (Ara_mean, na.rm = T)),
                  
                  
                  nTA_max = max (nTA_mean, na.rm = T),
                  nTA_min = min (nTA_mean, na.rm = T),
                  nTA_diff = (max (nTA_mean, na.rm = T) - min (nTA_mean, na.rm = T)),
                  
                  nDIC_max = max (nDIC_mean, na.rm = T),
                  nDIC_min = min (nDIC_mean, na.rm = T),
                  nDIC_diff = (max (nDIC_mean, na.rm = T) - min (nDIC_mean, na.rm = T)),
                  
                  n = n())

Seasonal_range<-Seasonal_range %>% 
 mutate_if(is.numeric, round, digits=2)
Seasonal_range
#Seasonal_range$pH_max_diff<-Seasonal_range$pH_max-mean()

#write.csv(Seasonal_range, "FLK_results/Table_S8_Month_mean_range.csv", row.names = F)

- Month Plots

Month_ploth<- ggplot(FLK.data) +
        MyTheme + 
        facet_grid(Sub_region~Zone)+
        scale_shape_manual(values=c(24, 25, 23, 22, 21))+
        Precipitation_fill+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(axis.title.x = element_blank() )

Year_ploth<- ggplot(Month_Stats) +
        MyTheme +  
        theme(axis.title.x = element_blank(), axis.text.x=element_text(angle = 10, vjust = 0.5))+
        Season_fill+
        Season_colour+
        facet_grid(Sub_region~Region)
        #scale_shape_manual(values=c(24, 25, 21))+
        #guides(fill=guide_legend(override.aes=list(shape=21)))+
        #theme(axis.title.x = element_blank() )

Month_Season_plotTA_DIC<- ggplot(FLK.data_filtered[
          FLK.data_filtered$Zone!="Oceanic",]) +
        MyTheme +  
        facet_grid(~Zone)+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        scale_x_continuous(limits = c(1,12),
                     expand = c(0.05, 0.05),
                     breaks = seq(1, 12, 1),
                     name=expression(paste("Month of the year")))+
        theme(#strip.text = element_blank(),
              legend.position = "none",
              axis.title.x = element_blank()
              )

Month_Season_plot<- ggplot(FLK.data_filtered) +
        MyTheme +  
        facet_grid(~Zone)+
        Zone_shapes4+
        #Region_fill+
        #Region_colour+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        scale_x_continuous(limits = c(1,12),
                   expand = c(0.05, 0.05),
                   breaks = seq(1, 12, 1),
                   name=expression(paste("Month of the year")))+
        theme(axis.title.x = element_blank())#,
        #       legend.position = "none")

Year_plot_2<- ggplot(Month_Stats)+
#[Month_Stats$Zone!="Oceanic",]) +
        MyTheme +  
        facet_grid(~Zone)+
        Zone_shapes4+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        #Season_fill+
        #Season_colour+
        theme(#axis.title.x = element_blank()#,
              #axis.text.y=element_blank(),
              legend.position = "bottom"
              )

Year_plot_3<- ggplot(Month_Stats, aes(fill=Sub_region, shape=Zone))+
#[Month_Stats$Zone!="Oceanic",]) +
        MyTheme +  
        Zone_shapes4+
        facet_grid(~Region)+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(#axis.title.x = element_blank()#,
              #axis.text.y=element_blank(),
              legend.position = "right",
              axis.title.x = element_blank(),
              axis.text.x = element_text(angle = 20, vjust = 0.5)
              )

Temperature

Figure Supp 2: Temperature variation by the region and shelf position by (A) month of the year and (B) season.

Temp_exp<- Month_Season_plot+
  geom_abline(slope = 0, intercept = mean_Op$OTem, color="grey")+
    scale_y_continuous(#limits = c(15,40),
                       name=(expression("Temperature"~(degree*C))),
                       breaks = seq(16, 40, 3),  
                       expand = c(0.05, 0.05)) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=Temperature_C, colour=Sub_region),
                span=0.6, alpha=0.2, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=Temperature_C, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=Temperature_C, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.3))
#Temp_exp

Temp_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$OTem, color="grey")+
   scale_y_continuous(limits = c(20,32.8),
                     expand = c(0.05, 0.05),
                     breaks = seq(16, 40, 3),
                     name=expression(paste("Temperature"~(degree*C))))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=Tem_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=Tem_min,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   stat_summary(aes (x=Zone, y=Tem_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
   stat_summary(aes (x=Zone, y=Tem_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#Temp_Y3

Figure 3A

Figure 3A: Temperature (C) variation by the region and shelf position. Left: monthly mean values, Right: Yearly mean values

Salinity

Figure S3: Salinity variation by the region and shelf position by (A) month of the year and (B) season.

Sal_exp<- Month_Season_plot+
  geom_abline(slope = 0, intercept = mean_Op$OSal, color="grey")+
   scale_y_continuous(#limits = c(15,40),
                       name=(expression("Salinity")),
                       breaks = seq(15, 40, 1),  
                       expand = c(0.05, 0.05)) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=BestSalinity, colour=Sub_region),
                span=0.8, alpha=0.2, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=BestSalinity, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=BestSalinity, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.3))
    
#Sal_exp

Sal_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$OSal, color="grey")+
   scale_y_continuous(limits = c(33,38),
                     expand = c(0.05, 0.05),
                     breaks = seq(33,38,1),
                     name=expression(paste("Salinity")))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=Sal_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=Sal_min,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   stat_summary(aes (x=Zone, y=Sal_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
   stat_summary(aes (x=Zone, y=Sal_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#Sal_Y3

Figure 3B

Figure 3B: Salinity variation by the region and shelf position. Left: monthly mean values, Right: Yearly mean values

TA

Figure S4: Total Alkalinity (TA) variation by the region and shelf position by (A) month of the year and (B) season.

Figure 3C

TA_exp<- Month_Season_plot+
   geom_abline(slope = 0, intercept = mean_Op$OTA, color="grey")+
   scale_y_continuous(#limits = c(2100,2500),
                     expand = c(0.05, 0.05),
                     breaks = seq(2100, 2500, 100),
                     name=expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  
  # geom_smooth(data=FLK.data, se=F, colour="gray70", alpha=0.5, size=0.5,
  #               aes(x=as.numeric(Month2), y=Temp.adj))+
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=TA_umol_kg, colour=Sub_region),
                span=0.8, alpha=0.2, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=TA_umol_kg, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=TA_umol_kg, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.3))

# 
# TA_Y2<- Year_plot_2+
#    geom_abline(slope = 0, intercept = mean_Op$OTA, color="grey")+
#    scale_y_continuous(#limits = c(2150,2550),
#                      expand = c(0.05, 0.05),
#                      breaks = seq(2200, 2500, 50),
#                     name=expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
#   
#    stat_summary(aes (x=Sub_region, y=TA_mean, colour=Sub_region),
#                 fun.data = "mean_cl_boot", geom = "errorbar", 
#                 width = 0.2)+
#    stat_summary(aes (x=Sub_region, y=TA_mean, fill=Sub_region, shape=Zone),
#                 fun.data = "mean_cl_boot", geom = "point", 
#                 size=2)
# #TA_Y2

TA_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$OTA, color="grey")+
   scale_y_continuous(limits = c(2130,2510),
                     expand = c(0.05, 0.05),
                     breaks = seq(2100, 2500, 100),
                     name=expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  
   geom_point(data=Seasonal_range, aes (x=Zone, y=TA_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=TA_min,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   # geom_segment(data=Seasonal_range, 
   #              aes(   x = Zone, y = TA_min, 
   #                  xend = Zone, yend = TA_max,
   #                  colour=Sub_region),
   #              #position = position_dodge(width = 0.6), 
   #              alpha=0.3)+
   stat_summary(aes (x=Zone, y=TA_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
   stat_summary(aes (x=Zone, y=TA_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#TA_Y3

Figure 3C: Total Alkalinity (TA) variation by the region and shelf position. Left: monthly mean values, Right: Yearly mean values

DIC

Figure S5: Dissolved Inorganic Carbon (DIC) variation by the region and shelf position by (A) month of the year and (B) season.

Figure 3D

DIC_exp<- Month_Season_plot+
   geom_abline(slope = 0, intercept = mean_Op$ODIC, color="grey")+
   scale_y_continuous(#limits = c(1780,2270),
                     expand = c(0.05, 0.05),
                     breaks = seq(1800, 2800, 100),
                     name=expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
    geom_smooth(aes (x=as.numeric(Month2),
                    y=DIC_umol_kg, colour=Sub_region),
                    span=0.8, alpha=0.2, se=F)+
   
    stat_summary(aes (x=as.numeric(Month2),
                      y=DIC_umol_kg, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width=0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=DIC_umol_kg, fill=Sub_region, shape=Zone),
                size=1,
                fun = "mean", geom = "point",
                position=position_dodge(width=0.3))
#DIC_exp

DIC_Y2<- Year_plot_2+
   geom_abline(slope = 0, intercept = mean_Op$ODIC, color="grey")+
   scale_y_continuous(#limits = c(1700,2900),
                     expand = c(0.05, 0.05),
                     #breaks = seq(1800, 2800, 100),
                     name=expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
    
   stat_summary(aes (x=Sub_region, y=DIC_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar",  width = 0.2)+
   stat_summary(aes (x=Sub_region, y=DIC_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point",
                size=2)
#DIC_Y2

DIC_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$ODIC, color="grey")+
   scale_y_continuous(limits = c(1820,2240),
                     expand = c(0.00, 0.00),
                     breaks = seq(1800, 2800, 100),
                     name=expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
  
   geom_point(data=Seasonal_range, aes (x=Zone, y=DIC_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=DIC_min,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
  # geom_segment(data=Seasonal_range, 
  #               aes(   x = Zone, y = DIC_min, 
  #                   xend = Zone, yend = DIC_max,
  #                   colour=Sub_region),
  #               #position = position_dodge(width = 0.6), 
  #               alpha=0.3)+
   stat_summary(aes (x=Zone, y=DIC_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
  stat_summary(aes (x=Zone, y=DIC_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#DIC_Y3

Figure 3D: Dissolved Inorganic Carbon (DIC) by the region and shelf position. Left: monthly mean values, Right: Yearly mean values

pCO2

Figure S6: pCO2 variation by the region and shelf position by (A) month of the year and (B) season.

pCO2_exp<- Month_Season_plot+
   geom_abline(slope = 0, intercept = mean_Op$OpCO2, color="grey")+
     scale_y_continuous(#limits = c(1,5.5),
                       name=expression(paste(pCO[2], " (", mu, " atm)")),
                       breaks = seq(200, 700, 100),
                       expand = c(0.05, 0.05)
                        ) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=pCO2_uatm, colour=Sub_region),
                span=0.8, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=pCO2_uatm, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
     stat_summary(aes (x=as.numeric(Month2), 
                      y=pCO2_uatm, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))
#pCO2_exp

pCO2_Y2<- Year_plot_2+
  geom_abline(slope = 0, intercept = mean_Op$OpCO2, color="grey")+
  scale_y_continuous(#limits = c(1,5.5),
                       name=expression(paste(pCO[2], 
                                             " (", mu, " atm)")),
                       breaks = seq(200, 600, 50),
                       expand = c(0.05, 0.05)
                        ) +
    
   stat_summary(aes (x=Sub_region, y=pCO2_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=2)+
  stat_summary(aes (x=Sub_region, y=pCO2_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar",  width = 0.2)
#pCO2_Y2

pCO2_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$OpCO2, color="grey")+
    scale_y_continuous(#limits = c(1,5.5),
                       name=expression(paste(pCO[2], 
                                             " (", mu, " atm)")),
                       breaks = seq(200, 600, 50),
                       expand = c(0.05, 0.05)
                        ) +
  
   geom_point(data=Seasonal_range, aes (x=Zone, y=pCO2_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=pCO2_min,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   stat_summary(aes (x=Zone, y=pCO2_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
  stat_summary(aes (x=Zone, y=pCO2_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#pCO2_Y3

pH

Figure S7: pH variation by the region and shelf position by (A) month of the year and (B) season.

pH_exp<- Month_Season_plot+
    geom_abline(slope = 0, intercept = mean_Op$OpH, color="grey")+
    scale_y_continuous(#limits = c(7.88,8.25),
                       name=(expression (pH)),
                       breaks = seq(0, 9, 0.1),
                       expand = c(0.02, 0)
                        ) +
    
    geom_smooth(aes (x=as.numeric(Month2),
                      y=pH_calculated, colour=Sub_region),
                span=0.8, se=F)+
    
    stat_summary(aes (x=as.numeric(Month2),
                      y=pH_calculated, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
     stat_summary(aes (x=as.numeric(Month2), 
                      y=pH_calculated, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))
#pH_exp

pH_Y2<- Year_plot_2+
  geom_abline(slope = 0, intercept = mean_Op$OpH, color="grey")+
    scale_y_continuous(#limits = c(1,5.5),
                       name=(expression (pH[calculated])),
                       breaks = seq(0, 9, 0.05),
                       expand = c(0.05, 0.05)
                        ) +
    
   stat_summary(aes (x=Sub_region, y=pH_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=2)+
    stat_summary(aes (x=Sub_region, y=pH_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar",  width = 0.2)
#pH_Y2

pH_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$OpH, color="grey")+
   scale_y_continuous(limits = c(7.87,8.22),
                       name=(expression (pH)),
                       breaks = seq(0, 9, 0.1),
                       expand = c(0.02, 0)
                        )+
  
   geom_point(data=Seasonal_range, aes (x=Zone, y=pH_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1, 
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=pH_min, 
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   # geom_segment(data=Seasonal_range, 
   #              aes(   x = Zone, y = pH_min, 
   #                  xend = Zone, yend = pH_max,
   #                  colour=Sub_region),
   #              #position = position_dodge(width = 0.6), 
   #              alpha=0.3)+
   stat_summary(aes (x=Zone, y=pH_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
  stat_summary(aes (x=Zone, y=pH_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#pH_Y3

Figure 3E

Figure 3E: pH by the region and shelf position. Left: monthly mean values, Right: Yearly mean values

Omega

Figure S8: Omega variation by the region and shelf position by (A) month of the year and (B) season.

Figure 3F

Omega_exp<- Month_Season_plot+
    geom_abline(slope = 0, intercept = mean_Op$OAra, color="grey")+
    scale_y_continuous(#limits = c(1,5.5),
                       name=(expression("\n" ~Omega[Ar])),
                       breaks = seq(1, 5, 0.5),
                       expand = c(0.05, 0.05)
                        ) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=Aragonite_Sat_W, colour=Sub_region),
                span=0.8, alpha=0.2, se=F
                #method = lm, formula = y ~ splines::bs(x, 3),
                )+
      stat_summary(aes (x=as.numeric(Month2),
                      y=Aragonite_Sat_W, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=Aragonite_Sat_W, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.3))

#Omega_exp

Om_Y2<- Year_plot_2+
  geom_abline(slope = 0, intercept = mean_Op$OAra, color="grey")+
  scale_y_continuous(#limits = c(1,5.5),
                       # name=(expression (
                       #   "Aragonite saturation state "(~Omega[Ar]))),
                      name=(expression (
                      ~Omega[Ar])),
                       breaks = seq(1, 5, 0.5),
                       expand = c(0.05, 0.05)
                        ) +
    
  stat_summary(aes (x=Sub_region, y=Ara_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar",  width = 0.2)+
  stat_summary(aes (x=Sub_region, y=Ara_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=2)
#Om_Y2

Om_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$OAra , color="grey")+
  scale_y_continuous(#limits = c(1,5.5),
                       # name=(expression (
                       #   "Aragonite saturation state "(~Omega[Ar]))),
                      name=(expression (
                      ~Omega[Ar])),
                       breaks = seq(1, 5, 0.5),
                       expand = c(0.1, 0.1)
                        ) +
  
   geom_point(data=Seasonal_range, aes (x=Zone, y=Ara_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1, 
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=Ara_min, 
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   # geom_segment(data=Seasonal_range, 
   #              aes(   x = Zone, y = Ara_min, 
   #                  xend = Zone, yend = Ara_max,
   #                  colour=Sub_region),
   #              #position = position_dodge(width = 0.6), 
   #              alpha=0.3)+
   stat_summary(aes (x=Zone, y=Ara_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
  stat_summary(aes (x=Zone, y=Ara_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#Om_Y3

Figure 3F: Aragonite saturation state (omega) by the region and shelf position. Left: monthly mean values, Right: Yearly mean values + SD, maximum monthly mean and minimum monthly mean.

Fig.3: Seasonal monthly plot

with summary

Figure 3: Monthly seasonal patterns in (A) Temperature, (B) Salinity, (C) Total Alkalinity (TA), (D) Dissolved Inorganic Carbon (DIC), and (E) pH and (F) aragonite saturation state (Ωar) in the Florida Reef Tract. The colors represent the biogeographical regions and the vertical panels separate the locations by shelf zone. The points show the (monthly mean values ± 95 CI) and the lines the smoothed curves for the data (method = ‘loess’ and formula ‘y ~ x’, span=0.8). Gray horizontal lines in each panel demarcate the mean values of the parameters in the oceanic samples.

5.2 Season raw values

- Season stats (all data)

  • do not use for further calculations since some months have more data than
  • can be used to compare the aggregated meaNs using MM
Seasonal_Stats<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season),
             summarise,

      Tem_mean = mean (Temperature_C, na.rm = T),
      Tem_sd = sd (Temperature_C, na.rm = T),
    
      Sal_mean = mean (BestSalinity, na.rm = T),
      Sal_sd = sd (BestSalinity, na.rm = T),
    
      TA_mean = mean (TA_umol_kg, na.rm = T),
      TA_sd = sd (TA_umol_kg, na.rm = T),
    
      nTA_mean = mean (n36TA, na.rm = T),
      nTA_sd = sd (n36TA, na.rm = T),
    
      nDIC_mean = mean (n36DIC, na.rm = T),
      nDIC_sd = sd (n36DIC, na.rm = T),
    
      DIC_mean = mean (DIC_umol_kg, na.rm = T),
      DIC_sd = sd (DIC_umol_kg, na.rm = T),
    
      pCO2_mean = mean (pCO2_uatm , na.rm = T),
      pCO2_sd = sd (pCO2_uatm , na.rm = T),
    
      pH_mean = mean (pH_calculated, na.rm = T),
      pH_sd = sd (pH_calculated, na.rm = T),
    
      Ara_mean = mean (Aragonite_Sat_W , na.rm = T),
      Ara_sd = sd (Aragonite_Sat_W , na.rm = T),
       n())

Seasonal_Stats<-Seasonal_Stats %>% 
 mutate_if(is.numeric, round, digits=2)
Seasonal_Stats

- Season stats (monthly mean)

Seasonal_Stats2<- ddply (Month_Stats, .(Zone, Sub_region, Season),
                         summarise,

                  Tem_M = mean (Tem_mean, na.rm = T),
                  #Tem_sd = sd (Tem_mean, na.rm = T),
                  Tem_se = std.error (Tem_mean, na.rm = T),

                  Sal_M = mean (Sal_mean, na.rm = T),
                  #Sal_sd = sd (Sal_mean, na.rm = T),
                  Sal_se = std.error (Sal_mean, na.rm = T),

                  TA_M = mean (TA_mean, na.rm = T),
                  #TA_sd = sd (TA_mean, na.rm = T),
                  TA_se = std.error (TA_mean, na.rm = T),
                  
                  DIC_M = mean (DIC_mean, na.rm = T),
                  #DIC_sd = sd (DIC_mean, na.rm = T),
                  DIC_se = std.error (DIC_mean, na.rm = T),
                  
                  #nTA_M = mean (nTA_mean, na.rm = T),
                  #nTA_sd = sd (nTA_mean, na.rm = T),
                  
                  #nDIC_M = mean (nDIC_mean, na.rm = T),
                  #nDIC_sd = sd (nDIC_mean, na.rm = T),

                  pCO2_M = mean (pCO2_mean , na.rm = T),
                  #pCO2_sd = sd (pCO2_mean , na.rm = T),
                  pCO2_se = std.error (pCO2_mean , na.rm = T),

                  pH_M = mean (pH_mean, na.rm = T),
                  #pH_sd = sd (pH_mean, na.rm = T),
                  pH_se = std.error (pH_mean, na.rm = T),

                  Ara_M = mean (Ara_mean , na.rm = T),
                  #Ara_sd = sd (Ara_mean , na.rm = T),
                  Ara_se = std.error (Ara_mean , na.rm = T),
                  n())

Seasonal_Stats2<-Seasonal_Stats2 %>% 
 mutate_if(is.numeric, round, digits=2)
Seasonal_Stats2
# write.csv(Seasonal_Stats2, "FLK_results/Table_S_Season_A.csv", row.names = F)

Note: SD is NA when calculating it based on monthly means (n=3 per season)

- Yearly stats (monthly mean)

Yearly_Stats<- ddply (Month_Stats, .(Zone, Sub_region),
                         summarise,

                  Tem_Y = mean (Tem_mean, na.rm = T),
                  Tem_sd = sd (Tem_mean, na.rm = T),

                  Sal_Y = mean (Sal_mean, na.rm = T),
                  Sal_sd = sd (Sal_mean, na.rm = T),

                  TA_Y = mean (TA_mean, na.rm = T),
                  TA_sd = sd (TA_mean, na.rm = T),

                  nTA_Y = mean (nTA_mean, na.rm = T),
                  nTA_sd = sd (nTA_mean, na.rm = T),

                  nDIC_Y = mean (nDIC_mean, na.rm = T),
                  nDIC_sd = sd (nDIC_mean, na.rm = T),

                  DIC_Y = mean (DIC_mean, na.rm = T),
                  DIC_sd = sd (DIC_mean, na.rm = T),

                  pCO2_Y = mean (pCO2_mean , na.rm = T),
                  pCO2_sd = sd (pCO2_mean , na.rm = T),

                  pH_Y = mean (pH_mean, na.rm = T),
                  pH_sd = sd (pH_mean, na.rm = T),

                  Ara_Y = mean (Ara_mean , na.rm = T),
                  Ara_sd = sd (Ara_mean , na.rm = T),
                  n())

Yearly_Stats<-Yearly_Stats %>% 
 mutate_if(is.numeric, round, digits=2)
Yearly_Stats
# write.csv(Yearly_Stats, "FLK_results/Table_1_Year_A.csv", row.names = F)

Note: SD is NA when calculating it based on monthly means (n=3 per season)

5.3 Delta months values

# 1. Get the oceanic mean values per month-year 

  WS.reef<-join(WS.reef, mean_Open_MY, 
                 type = "left", by=c("MY", "Month"))

# 2. and subtract them from the reef data
  # Delta TA
  WS.reef$dTA_MY<-WS.reef$TA_umol_kg-WS.reef$OTA_my
  # Delta DIC
  WS.reef$dDIC_MY<-WS.reef$DIC_umol_kg-WS.reef$ODIC_my
  # Delta nTA
  WS.reef$dnTA_MY<-WS.reef$n36TA-WS.reef$OnTA_my
  # Delta nDIC
  WS.reef$dnDIC_MY<-WS.reef$n36DIC-WS.reef$OnDIC_my
  # Delta pCO2
  WS.reef$dpCO2_MY<-WS.reef$pCO2_uatm-WS.reef$OpCO2_O
  # Delta pH
  WS.reef$dpH_MY<-WS.reef$pH_calculated-WS.reef$OpH_O
   # Delta Omega
  WS.reef$dOme_MY<-WS.reef$Aragonite_Sat_W-WS.reef$OAra_O
  
 # head(WS.reef)
 #summary(WS.reef$Season, digits=2)

- Delta month stats

dMonth_Stats<- ddply (WS.reef, .(Zone, Sub_region, Month2, Season, Region),
                            summarise,
                  dTA_mean = mean (dTA_MY, na.rm = T),
                  dTA_sd = sd (dTA_MY, na.rm = T),
                  #dTA_se = std.error (dTA_MY, na.rm = T),
                  
                  dnTA_mean = mean (dnTA_MY, na.rm = T),
                  dnTA_sd = sd (dnTA_MY, na.rm = T),
                 
                  dDIC_mean = mean (dDIC_MY, na.rm = T),
                  dDIC_sd = mean (dDIC_MY, na.rm = T),
                  #dDIC_se = std.error (dDIC_MY, na.rm = T),
                  
                  dnDIC_mean = mean (dnDIC_MY, na.rm = T),
                  dnDIC_sd = sd (dnDIC_MY, na.rm = T),
                  
                  dpCO2_mean = mean (dpCO2_MY , na.rm = T),
                  dpCO2_sd = sd (dpCO2_MY , na.rm = T),
                  #dpCO2_se = std.error (dpCO2_MY, na.rm = T),
                  
                  dpH_mean = mean (dpH_MY, na.rm = T),
                  dpH_sd = sd (dpH_MY, na.rm = T),
                  #dPH_se = std.error (dpH_MY, na.rm = T),
                  
                  dAra_mean = mean (dOme_MY , na.rm = T),
                  dAra_sd = sd (dOme_MY , na.rm = T)#,
                  #dAra_se = std.error (dOme_MY, na.rm = T),
                  )

dMonth_Stats<-dMonth_Stats %>% 
 mutate_if(is.numeric, round, digits=3)
dMonth_Stats
#write.csv(dMonth_Stats, "FLK_results/Table_S9_Month_StatsDeltas.csv", row.names = F)

Spring.data<-WS.reef[WS.reef$Season=="Spring", ]
Summer.data<-WS.reef[WS.reef$Season=="Summer", ]
Fall.data<-WS.reef[WS.reef$Season=="Fall", ]
Winter.data<-WS.reef[WS.reef$Season=="Winter", ]

Seasonal range

Seasonal_range_d<-ddply (dMonth_Stats, .(Zone, Sub_region),
                            summarise,
                  
                  dTA_max = max (dTA_mean, na.rm = T),
                  dTA_min = min (dTA_mean, na.rm = T),
                  dTA_diff = (max (dTA_mean, na.rm = T) - min (dTA_mean, na.rm = T)),
                  
                  dDIC_max = max (dDIC_mean, na.rm = T),
                  dDIC_min = min (dDIC_mean, na.rm = T),
                  dDIC_diff = (max (dDIC_mean, na.rm = T) - min (dDIC_mean, na.rm = T)),
                  
                  dpCO2_max = max (dpCO2_mean, na.rm = T),
                  dpCO2_min = min (dpCO2_mean, na.rm = T),
                  dpCO2_dif = (max (dpCO2_mean, na.rm = T) - min (dpCO2_mean, na.rm = T)),
                  
                  dpH_max = max (dpH_mean, na.rm = T),
                  dpH_min = min (dpH_mean, na.rm = T),
                  dpH_diff = (max (dpH_mean, na.rm = T) - min (dpH_mean, na.rm = T)),
                  
                  dAra_max = max (dAra_mean, na.rm = T),
                  dAra_min = min (dAra_mean, na.rm = T),
                  dAra_diff = (max (dAra_mean, na.rm = T) - min (dAra_mean, na.rm = T)),
                  
                  n = n())

Seasonal_range_d<-Seasonal_range_d %>% 
 mutate_if(is.numeric, round, digits=3)
Seasonal_range_d
#write.csv(Seasonal_range_d, "FLK_results/Table_S8_Month_mean_range_d.csv", row.names = F)

- Delta month plots (Supplementary)

Delta_plot<- ggplot(WS.reef) +
        MyTheme +  
        facet_grid(Sub_region~Zone)+
        scale_shape_manual(values=c(24, 25, 23, 22, 21))+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank())

DeltaYear_plot<- ggplot(dMonth_Stats) +
        MyTheme +  
        facet_grid(Sub_region~Region)+
        Season_fill+
        Season_colour+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              axis.text.x = element_text(angle = 10,
                                         vjust = 0.5))
        
Delta_plot_month<- ggplot(WS.reef) +
        MyTheme +  
        geom_abline(slope = 0, intercept = 0, color="grey")+
        facet_grid(~Zone)+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        scale_x_continuous(limits = c(1,12),
                     expand = c(0.05, 0.05),
                     breaks = seq(1, 12, 1),
                     name=expression(paste("Month of the year")))+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom")

–dTA

Figure Supp 4: Total Alkalinity (TA) variation by the region and shelf position by (A) month of the year and (B) season.

–dDIC

Figure Supp 5: Total Alkalinity (TA) variation by the region and shelf position by (A) month of the year and (B) season.

–dPCO2

Figure S6: pCO2 variation by the region and shelf position by (A) month of the year and (B) season.

–dpH

Figure S7: pH variation by the region and shelf position by (A) month of the year and (B) season.

–dOmega

Figure S8: OMEGA variation by the region and shelf position by (A) month of the year and (B) season.

5.4 Delta season values

- Delta season stats (all data)

  dSeason_Stats<- ddply (WS.reef, .(Zone, Sub_region, Season),
                            summarise,
                  dTA_mean = mean (dTA_MY, na.rm = T),
                  dTA_sd = sd (dTA_MY, na.rm = T),
                  
                  dnTA_mean = mean (dnTA_MY, na.rm = T),
                  dnTA_sd = sd (dnTA_MY, na.rm = T),
                 
                  dDIC_mean = mean (dDIC_MY, na.rm = T),
                  dDIC_sd = mean (dDIC_MY, na.rm = T),
                  
                  #dnDIC_mean = mean (dnDIC_MY, na.rm = T),
                  #dnDIC_sd = sd (dnDIC_MY, na.rm = T),
                  
                  #dpCO2_mean = mean (dpCO2_MY , na.rm = T),
                  #dpCO2_sd = sd (dpCO2_MY , na.rm = T),
                  
                  dpH_mean = mean (dpH_MY, na.rm = T),
                  dpH_sd = mean (dpH_MY, na.rm = T),
                  
                  dAra_mean = mean (dOme_MY , na.rm = T),
                  dAra_sd = mean (dOme_MY , na.rm = T),
                  n())

dSeason_Stats<-dSeason_Stats %>% 
 mutate_if(is.numeric, round, digits=3)
dSeason_Stats

- Delta season stats (monthly mean)

dSeasonal_Stats2<- ddply (dMonth_Stats,
                          .(Zone, Season, Sub_region),
                         summarise,

                  dTA_M = mean (dTA_mean, na.rm = T),
                  dTA_sd = sd (dTA_mean, na.rm = T),
                  dTA_se = std.error (dTA_mean, na.rm = T),
                  
                  dDIC_M = mean (dDIC_mean, na.rm = T),
                  dDIC_sd = sd (dDIC_mean, na.rm = T),
                  dDIC_se = std.error (dDIC_mean, na.rm = T),
                  
                  #dnTA_M = mean (dnTA_mean, na.rm = T),
                  #dnTA_sd = sd (dnTA_mean, na.rm = T),
                  
                  #dnDIC_M = mean (dnDIC_mean, na.rm = T),
                  #dnDIC_sd = sd (dnDIC_mean, na.rm = T),

                  dpCO2_M = mean (dpCO2_mean , na.rm = T),
                  dpCO2_sd = sd (dpCO2_mean , na.rm = T),
                  dpCO2_se = std.error (dpCO2_mean , na.rm = T),

                  dpH_M = mean (dpH_mean, na.rm = T),
                  dpH_sd = sd (dpH_mean, na.rm = T),
                  dpH_se = std.error (dpH_mean, na.rm = T),

                  dAra_M = mean (dAra_mean , na.rm = T),
                  dAra_sd = sd (dAra_mean , na.rm = T),
                  dAra_se = std.error (dAra_mean , na.rm = T),
                  n())

dSeasonal_Stats2<-dSeasonal_Stats2 %>% 
 mutate_if(is.numeric, round, digits=3)
dSeasonal_Stats2
#write.csv(dSeasonal_Stats2, "FLK_results/Table_2_SeasonDelta_B.csv", row.names = F)

Note: SD is NA when calculating it based on monthly meand (n=3 per season)

- Delta yearly stats (monthly mean)

dYearly_Stats<- ddply (dMonth_Stats, .(Zone, Sub_region),
                         summarise,

                  dTA_M = mean (dTA_mean, na.rm = T),
                  dTA_sd = sd (dTA_mean, na.rm = T),
                  #dTA_se = std.error (dTA_mean, na.rm = T),
                  
                  dDIC_M = mean (dDIC_mean, na.rm = T),
                  dDIC_sd = sd (dDIC_mean, na.rm = T),
                  #dDIC_se = std.error (dDIC_mean, na.rm = T),
                  
                  dnTA_M = mean (dnTA_mean, na.rm = T),
                  dnTA_sd = sd (dnTA_mean, na.rm = T),
                  
                  dnDIC_M = mean (dnDIC_mean, na.rm = T),
                  dnDIC_sd = sd (dnDIC_mean, na.rm = T),

                  dpCO2_M = mean (dpCO2_mean , na.rm = T),
                  dpCO2_sd = sd (dpCO2_mean , na.rm = T),
                  #dpCO2_se = std.error (dpCO2_mean , na.rm = T),

                  dpH_M = mean (dpH_mean, na.rm = T),
                  dpH_sd = sd (dpH_mean, na.rm = T),
                  #dpH_se = std.error (dpH_mean, na.rm = T),

                  dAra_M = mean (dAra_mean , na.rm = T),
                  dAra_sd = sd (dAra_mean , na.rm = T),
                  #dAra_se = std.error (dAra_mean , na.rm = T),
                  n())

dYearly_Stats<-dYearly_Stats %>% 
 mutate_if(is.numeric, round, digits=3)
dYearly_Stats
#write.csv(dYearly_Stats, "FLK_results/Table_1b_delta_year.csv", row.names = F)

- Yearly summ (monthly mean)

dYear_Add<- ddply (dMonth_Stats, .(Zone, Sub_region),
           summarise,
  su_dTA_Y = sum (dTA_mean, na.rm = T),
  #m_TA_Y = mean (dTA_mean, na.rm = T),
  #sd_TA_Y = sd (dTA_mean, na.rm = T),
  
  su_dDIC_Y = sum (dDIC_mean, na.rm = T),
  #m_dDIC_Y = mean (dDIC_mean, na.rm = T),
  #sd_dDIC_Y = sd (dDIC_mean, na.rm = T),
  

  su_dpCO2_Y = sum (dpCO2_mean, na.rm = T),
  #m_pCO2_Y = mean (dpCO2_mean, na.rm = T),
  #sd_pCO2_Y = sd (dpCO2_mean, na.rm = T),
  
  su_dpH_Y = sum (dpH_mean, na.rm = T),
  #m_pH_Y = mean (dpH_mean, na.rm = T),
  #sd_pH_Y = sd (dpH_mean, na.rm = T),
  
  su_dAra_Y = sum (dAra_mean, na.rm = T),
  #m_Ara_Y = mean (dAra_mean, na.rm = T),
  #sd_Ara_Y = sd (dAra_mean, na.rm = T),
  n())

dYear_Add<-dYear_Add %>% 
 mutate_if(is.numeric, round, digits=2)
dYear_Add
#write.csv(dYear_Add, "FLK_results/Table_1_year_byMM.csv", row.names = F)

- Yearly summ (indiviual years)

dYear_Add2<- ddply (WS.reef, .(Zone, Sub_region, MY, Region, Year),
                            summarise,
                  dTA_mean = mean (dTA_MY, na.rm = T),
                  dTA_sd = sd (dTA_MY, na.rm = T),
                  #dTA_se = std.error (dTA_MY, na.rm = T),
                  
                  dnTA_mean = mean (dnTA_MY, na.rm = T),
                  dnTA_sd = sd (dnTA_MY, na.rm = T),
                 
                  dDIC_mean = mean (dDIC_MY, na.rm = T),
                  dDIC_sd = mean (dDIC_MY, na.rm = T),
                  #dDIC_se = std.error (dDIC_MY, na.rm = T),
                  
                  dnDIC_mean = mean (dnDIC_MY, na.rm = T),
                  dnDIC_sd = sd (dnDIC_MY, na.rm = T),
                  
                  dpCO2_mean = mean (dpCO2_MY , na.rm = T),
                  dpCO2_sd = sd (dpCO2_MY , na.rm = T),
                  #dpCO2_se = std.error (dpCO2_MY, na.rm = T),
                  
                  dpH_mean = mean (dpH_MY, na.rm = T),
                  dpH_sd = mean (dpH_MY, na.rm = T),
                  #dPH_se = std.error (dpH_MY, na.rm = T),
                  
                  dAra_mean = mean (dOme_MY , na.rm = T),
                  dAra_sd = mean (dOme_MY , na.rm = T),
                  #dAra_se = std.error (dOme_MY, na.rm = T),
                  n())

dYear_Add2<-dYear_Add2 %>% 
 mutate_if(is.numeric, round, digits=3)
dYear_Add2
dYear_Add2<-dYear_Add2[dYear_Add2$Year>2014, ]
dYear_Add2<-dYear_Add2[dYear_Add2$Year<2022, ]

dYear_Add3<- ddply (dYear_Add2, .(Zone, Sub_region, Year),
           summarise,
  su_dTA_Y = sum (dTA_mean, na.rm = T),
  #m_TA_Y = mean (dTA_mean, na.rm = T),
  #sd_TA_Y = sd (dTA_mean, na.rm = T),
  
  su_dDIC_Y = sum (dDIC_mean, na.rm = T),
  #m_dDIC_Y = mean (dDIC_mean, na.rm = T),
  #sd_dDIC_Y = sd (dDIC_mean, na.rm = T),
  

  su_dpCO2_Y = sum (dpCO2_mean, na.rm = T),
  #m_pCO2_Y = mean (dpCO2_mean, na.rm = T),
  #sd_pCO2_Y = sd (dpCO2_mean, na.rm = T),
  
  su_dpH_Y = sum (dpH_mean, na.rm = T),
  #m_pH_Y = mean (dpH_mean, na.rm = T),
  #sd_pH_Y = sd (dpH_mean, na.rm = T),
  
  su_dAra_Y = sum (dAra_mean, na.rm = T),
  #m_Ara_Y = mean (dAra_mean, na.rm = T),
  #sd_Ara_Y = sd (dAra_mean, na.rm = T),
  n())

dYear_Add3<-dYear_Add3 %>% 
 mutate_if(is.numeric, round, digits=2)
dYear_Add3

5.5 Seasonal models

season.data<-WS.reef[WS.reef$Extreme=="Normal", ]
season.data<-droplevels(season.data)
season.data$Zone<-factor(season.data$Zone, levels = c("Offshore", "Mid channel", "Inshore"))
#summary(season.data)

inshore.season.data<-season.data[season.data$Zone=="Inshore", ]
midchanel.season.data<-season.data[season.data$Zone=="Mid channel", ]
ofshore.season.data<-season.data[season.data$Zone=="Offshore", ]

LMER - TA month

  hist(FLK.data_filtered$TA_umol_kg)

  shapiro.test(FLK.data_filtered$TA_umol_kg) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  FLK.data_filtered$TA_umol_kg
## W = 0.81653, p-value < 2.2e-16
# 
#   dTA_season<-lmer(dTA_MY~  Zone + Sub_region + Season +
#                            Zone:Sub_region + Zone:Season + Sub_region:Season+   
#                            (1|SiteID), data=season.data)
  
  TA_month_0<-lmer(TA_umol_kg~  Zone * Sub_region * Month +
                           (1|SiteID), data=FLK.data_filtered)
  #anova(TA_month_0)
  
  TA_month<-lmer(TA_umol_kg~  Zone + Sub_region + Month +
                              Zone:Sub_region + Zone:Month + Sub_region:Month +
                              (1|SiteID), data=season.data)
  
  #summary(dTA_season)    
  av.TA_month<-(anova(TA_month))
  av.TA_month
  ranova(TA_month)
  #step(TA_month)
  
  plot(TA_month)

    par(mfrow=c(1,2))
    qqnorm(resid(TA_month))
    acf(resid(TA_month), main="acf(resid(dTA Season))")

    par(mfrow=c(1,1))
  
  #summ(TA_month, scale = TRUE)
  #plot_summs(TA_month)
  
  TA_mo.emmc<-emmeans(TA_month, ~Zone*Month, by="Sub_region")
    TA_mon.emmc<-multcomp::cld(TA_mo.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    #TA_mon.emmc<-TA_mon.emmc[order(TA_mon.emmc$Zone, TA_mon.emmc$Month), ]
  TA_mon.emmc

LMER - TA season

  hist(season.data$TA_umol_kg)

  shapiro.test(season.data$TA_umol_kg) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$TA_umol_kg
## W = 0.84701, p-value < 2.2e-16
# 
#   dTA_season<-lmer(dTA_MY~  Zone + Sub_region + Season +
#                            Zone:Sub_region + Zone:Season + Sub_region:Season+   
#                            (1|SiteID), data=season.data)
  
  TA_season_0<-lmer(TA_umol_kg~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  anova(TA_season_0)
  TA_season<-lmer(TA_umol_kg~ Zone + Sub_region + Season +
                              Zone:Sub_region + 
                              Zone:Season + 
                              Sub_region:Season +
                              (1|SiteID), data=season.data)
  anova(TA_season_0, TA_season)
  #summary(av.TA_season)    
  av.TA_season<-(anova(TA_season))
  av.TA_season
  ranova(TA_season)
  #step(TA_season)
  
  plot(TA_season)

  par(mfrow=c(1,2))
  qqnorm(resid(TA_season))
  acf(resid(TA_season), main="acf(resid(TA Season))")

  par(mfrow=c(1,1))
  
  #summ(av.TA_season, scale = TRUE)
  #plot_summs(TA_season)
  
  TA_se.emmc<-emmeans(TA_season, ~Zone*Season, by="Sub_region")
    TA_seas.emmc<-multcomp::cld(TA_se.emmc)
    TA_seas.emmc
  TA_se.emmc2<-emmeans(TA_season, ~Sub_region*Season, by="Zone")
    TA_seas.emmc2<-multcomp::cld(TA_se.emmc2)
    TA_seas.emmc2

LMER - all dTA - MODEL 13

  hist(season.data$dTA_MY)

  shapiro.test(season.data$dTA_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dTA_MY
## W = 0.82647, p-value < 2.2e-16
# 
#   dTA_season<-lmer(dTA_MY~  Zone + Sub_region + Season +
#                            Zone:Sub_region + Zone:Season + Sub_region:Season+   
#                            (1|SiteID), data=season.data)
  
  dTA_season<-lmer(dTA_MY~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dTA_season)    
  av.dTA_season<-(anova(dTA_season))
  av.dTA_season
  ranova(dTA_season)
  #step(dTA_season)
  
  plot(dTA_season)

  par(mfrow=c(1,2))
  qqnorm(resid(dTA_season))
  acf(resid(dTA_season), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  
  #summ(dTA_season, scale = TRUE)
  #plot_summs(dTA_season)
 dTA_ses.emmc<-emmeans(dTA_season, ~Season*Sub_region, by="Zone")
    dTA_ses.emmc<-multcomp::cld(dTA_ses.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dTA_ses.emmc<-dTA_ses.emmc[order(dTA_ses.emmc$Zone, 
                                     dTA_ses.emmc$Season, 
                                     dTA_ses.emmc$Sub_region), ]
  dTA_ses.emmc
  dTA_ses.emmc[,-c(3)] %>% kable("html", digits=2, row.names = F,
                                 caption = "Seasonal dTA") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 16) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 17, 32) %>%
      pack_rows(., "Inshore", 33, 48)
Seasonal dTA
Season Sub_region emmean SE df lower.CL upper.CL .group
Offshore
Winter BB 1.05 11.74 223.40 -22.10 24.19 1
Winter UK 3.89 10.07 257.16 -15.94 23.72 1
Winter MK 4.60 9.68 230.62 -14.47 23.66 1
Winter LK 1.94 8.31 220.73 -14.43 18.32 1
Spring BB -3.90 11.17 183.03 -25.93 18.13 1
Spring UK -1.98 9.51 214.78 -20.72 16.76 1
Spring MK -7.46 8.76 162.74 -24.76 9.84 1
Spring LK -11.50 7.54 157.14 -26.39 3.39 1
Summer BB -5.51 12.08 246.64 -29.30 18.28 1
Summer UK -4.77 10.28 277.89 -25.00 15.47 1
Summer MK -24.72 9.86 246.64 -44.14 -5.29 1
Summer LK -10.43 8.54 246.64 -27.26 6.39 1
Fall BB -0.83 10.90 170.54 -22.35 20.68 1
Fall UK -0.58 9.50 216.63 -19.31 18.15 1
Fall MK -1.32 8.76 162.74 -18.62 15.98 1
Fall LK -3.35 7.62 164.25 -18.40 11.69 1
Mid-Channel
Winter BB 8.02 12.08 246.64 -15.77 31.81 34
Winter UK 10.66 12.45 271.51 -13.86 35.17 34
Winter MK 25.24 9.68 230.62 6.17 44.31 4
Winter LK 13.55 8.90 171.14 -4.01 31.11 4
Spring BB -8.62 12.09 243.16 -32.43 15.19 234
Spring UK -3.03 11.74 223.36 -26.17 20.12 234
Spring MK -37.30 8.64 154.39 -54.36 -20.24 123
Spring LK -49.11 8.40 139.56 -65.72 -32.50 12
Summer BB -13.78 12.08 246.64 -37.57 10.01 234
Summer UK -5.58 12.87 297.18 -30.91 19.74 234
Summer MK -73.30 9.86 246.64 -92.72 -53.87 1
Summer LK -76.55 9.86 246.64 -95.97 -57.12 1
Fall BB 4.06 11.16 186.76 -17.94 26.07 34
Fall UK 0.63 11.74 223.36 -22.52 23.77 234
Fall MK 7.17 8.89 172.13 -10.39 24.72 4
Fall LK -11.66 8.52 146.93 -28.49 5.17 234
Inshore
Winter BB 40.60 11.74 223.41 17.45 63.74 67
Winter UK 48.74 10.51 298.97 28.07 69.41 67
Winter MK 57.00 10.27 281.16 36.77 77.22 7
Winter LK 7.36 9.19 189.81 -10.77 25.48 56
Spring BB -62.57 11.17 183.07 -84.61 -40.54 34
Spring UK -57.07 9.86 246.64 -76.50 -37.64 34
Spring MK -80.92 8.40 139.55 -97.53 -64.31 3
Spring LK -124.49 8.29 132.95 -140.89 -108.09 2
Summer BB -46.25 12.08 246.64 -70.04 -22.45 34
Summer UK -35.23 9.86 246.64 -54.66 -15.81 45
Summer MK -148.77 10.06 262.68 -168.58 -128.95 12
Summer LK -183.91 10.27 281.21 -204.14 -163.69 1
Fall BB 26.25 10.65 158.44 5.20 47.29 67
Fall UK 44.42 9.86 246.64 24.99 63.85 67
Fall MK 16.80 8.90 171.08 -0.77 34.36 67
Fall LK -63.22 8.52 146.93 -80.05 -46.39 34
  dTA_year.emmc<-emmeans(dTA_season, ~Sub_region*Zone)
    dTA_year.emmc<-multcomp::cld(dTA_year.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dTA_year.emmc<-dTA_year.emmc[order(dTA_year.emmc$Zone, 
                                      dTA_year.emmc$Sub_region), ]
  #dTA_year.emmc
  
  dTA_year.emmc[,-c(2)] %>% kable("html", digits=2, row.names = F,
                                  caption = "Year dTA") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 4) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 5, 8) %>%
      pack_rows(., "Inshore", 9, 12)
Year dTA
Sub_region emmean SE df lower.CL upper.CL .group
Offshore
BB -2.30 6.34 21.07 -15.49 10.89 34
UK -0.86 5.39 24.81 -11.97 10.25 4
MK -7.23 5.13 20.50 -17.92 3.47 34
LK -5.84 4.44 20.23 -15.09 3.41 4
Mid-Channel
BB -2.58 6.51 23.52 -16.03 10.88 34
UK 0.67 6.67 25.91 -13.05 14.39 4
MK -19.55 5.14 20.51 -30.24 -8.85 234
LK -30.94 4.98 18.14 -41.40 -20.49 23
Inshore
BB -10.49 6.32 20.76 -23.64 2.65 234
UK 0.21 5.47 26.46 -11.03 11.46 4
MK -38.97 5.21 21.68 -49.78 -28.17 2
LK -91.07 5.05 19.19 -101.64 -80.49 1

Figure 4A: Model

dTA_ses_2.emmc<-as.data.frame(dTA_ses.emmc)
dTA_ye_3.emmc<-as.data.frame(dTA_year.emmc)
dTA_ye_3.emmc$Season<-"Mean"

dTA_all_4<-rbind(dTA_ses_2.emmc, dTA_ye_3.emmc)
dTA_all_4$Zone<-factor(dTA_all_4$Zone, 
                          levels=c("Inshore" , "Mid channel", "Offshore"))


DeltaYearTA<- ggplot(dTA_all_4, aes(x=Season, y=emmean, fill=Sub_region)) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))+

    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.03, 0.03),
                     #breaks = seq(-800, 800, 50),
                     name=expression(paste(Delta, "TA  (", mu, "mol ", ~kg^-1, ")")))+
    geom_bar(position = "dodge", color="black", 
           stat = "summary",
           fun = "mean")+
  geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE), width=0.2,
                 position=position_dodge(.9)) 
DeltaYearTA

LMER - dTA Inshore

# Inshore dTA
  hist(inshore.season.data$dTA_MY)

  shapiro.test(inshore.season.data$dTA_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$dTA_MY
## W = 0.9743, p-value = 1.971e-06
  dTA_season_in<-lmer(dTA_MY~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
  #summary(dTA_season_in)    
  av.dTA_season_in<-anova(dTA_season_in)
  av.dTA_season_in
  ranova(dTA_season_in)
  #step(dTA_season_in)
  
  plot(dTA_season_in)

    par(mfrow=c(1,2))
    qqnorm(resid(dTA_season_in))
    acf(resid(dTA_season_in), main="acf(resid(dTA Season))")

    par(mfrow=c(1,1))
    #summ(dTA_season_in, scale = TRUE)
    #plot_summs(dTA_season_in)
  
  dTA_ses_in.emmc<-emmeans(dTA_season_in, ~ Sub_region*Season)
    dTA_ses_in.emmc<-multcomp::cld(dTA_ses_in.emmc)
    #dTA_ses_in.emmc<-as.data.frame(dTA_ses_in.emmc[complete.cases(dTA_ses_in.emmc),])
    dTA_ses_in.emmc<-dTA_ses_in.emmc[order(dTA_ses_in.emmc$Season,
                                           dTA_ses_in.emmc$Sub_region), ]
  dTA_ses_in.emmc

LMER - DIC season

  hist(season.data$DIC_umol_kg)

  shapiro.test(season.data$DIC_umol_kg) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$DIC_umol_kg
## W = 0.91454, p-value < 2.2e-16
  DIC_season_0<-lmer(DIC_umol_kg~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(DIC_season_0)    
  av.DIC_season<-(anova(DIC_season_0))
  av.DIC_season
  ranova(DIC_season_0)
  #step(DIC_season_0)
  
  plot(DIC_season_0)

    par(mfrow=c(1,2))
    qqnorm(resid(DIC_season_0))
    acf(resid(DIC_season_0), main="acf(resid(DIC Season))")

    par(mfrow=c(1,1))
  
  #summ(av.TA_season, scale = TRUE)
  #plot_summs(av.DIC_season)
  
  DIC_se.emmc<-emmeans(DIC_season_0, ~Zone*Season, by="Sub_region")
    DIC_seas.emmc<-multcomp::cld(DIC_se.emmc)
    DIC_seas.emmc
  DIC_se.emmc2<-emmeans(DIC_season_0, ~Sub_region*Season, by="Zone")
    DIC_seas.emmc2<-multcomp::cld(TA_se.emmc2)
    DIC_seas.emmc2

LMER - all dDIC - MODEL 14

# Inshore Omega
  hist(season.data$dDIC_MY)

  shapiro.test(season.data$dDIC_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dDIC_MY
## W = 0.87909, p-value < 2.2e-16
  # dDIC_season<-lmer(dDIC_MY~ Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  
  dDIC_season<-lmer(dDIC_MY~ Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dDIC_season)    
  av.dDIC_season<-anova(dDIC_season)
  av.dDIC_season
  ranova(dDIC_season)
  step(dDIC_season)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik   AIC    LRT Df Pr(>Chisq)  
## <none>                    50 -6071.5 12243                       
## (1 | SiteID)          0   49 -6074.0 12246 5.0185  1    0.02508 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                        Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)
## Zone:Sub_region:Season          0 102157  5675.4    18 1113.1  2.4361 0.000722
##                           
## Zone:Sub_region:Season ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dDIC_MY ~ Zone * Sub_region * Season + (1 | SiteID)
  plot(dDIC_season)

    par(mfrow=c(1,2))
    qqnorm(resid(dDIC_season))
    acf(resid(dDIC_season), main="acf(resid(dTA Season))")

    par(mfrow=c(1,1))
    #summ(dDIC_season, scale = TRUE)
    #plot_summs(dDIC_season)
  
 dDIC_ses.emmc<-emmeans(dDIC_season, ~Season*Sub_region, by="Zone")
    dDIC_ses.emmc<-multcomp::cld(dDIC_ses.emmc)
    #dDIC_ses.emmc<-as.data.frame(dDIC_ses.emmc[complete.cases(dDIC_ses.emmc),])
    dDIC_ses.emmc<-dDIC_ses.emmc[order(dDIC_ses.emmc$Zone, 
                                     dDIC_ses.emmc$Season, 
                                     dDIC_ses.emmc$Sub_region), ]
  #dDIC_ses.emmc

  dDIC_ses.emmc[,-c(3)] %>% kable("html", digits=2, row.names = F,
                                 caption = "Seasonal dDIC") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 16) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 17, 32) %>%
      pack_rows(., "Inshore", 33, 48)
Seasonal dDIC
Season Sub_region emmean SE df lower.CL upper.CL .group
Offshore
Winter BB -1.15 12.79 151.53 -26.42 24.11 1
Winter UK -0.09 10.92 175.49 -21.64 21.47 1
Winter MK 7.93 10.53 156.21 -12.87 28.73 1
Winter LK 7.32 8.84 138.04 -10.16 24.79 1
Spring BB -0.53 12.23 126.75 -24.73 23.67 1
Spring UK -1.51 10.36 146.50 -21.99 18.97 1
Spring MK -13.60 9.63 112.46 -32.69 5.48 1
Spring LK -6.09 8.29 109.38 -22.52 10.35 1
Summer BB 5.88 13.12 166.46 -20.02 31.78 1
Summer UK -2.98 11.12 188.57 -24.92 18.96 1
Summer MK -20.44 10.71 166.46 -41.58 0.71 1
Summer LK 0.35 9.67 193.08 -18.73 19.43 1
Fall BB 3.55 11.96 117.87 -20.14 27.24 1
Fall UK 2.73 10.36 147.09 -17.73 23.20 1
Fall MK 0.39 9.63 112.46 -18.70 19.47 1
Fall LK 1.17 8.37 113.66 -15.41 17.76 1
Mid-Channel
Winter BB 10.65 13.12 166.46 -15.25 36.55 45
Winter UK 1.74 13.48 183.28 -24.87 28.34 345
Winter MK 24.46 10.53 156.21 3.66 45.26 45
Winter LK 31.79 9.77 118.05 12.45 51.13 5
Spring BB -21.90 13.13 165.36 -47.82 4.02 12345
Spring UK -29.06 12.79 151.50 -54.33 -3.79 1234
Spring MK -65.71 9.51 107.15 -84.57 -46.86 1
Spring LK -53.48 9.28 97.74 -71.90 -35.06 123
Summer BB 4.03 13.12 166.46 -21.87 29.92 45
Summer UK -3.00 13.90 201.96 -30.41 24.41 2345
Summer MK -59.92 10.71 166.46 -81.07 -38.78 12
Summer LK -57.79 11.12 189.74 -79.72 -35.86 123
Fall BB 22.16 12.21 127.83 -2.00 46.33 45
Fall UK 15.78 12.79 151.50 -9.49 41.04 45
Fall MK 22.59 9.76 118.32 3.26 41.92 45
Fall LK 5.03 9.39 102.32 -13.60 23.66 45
Inshore
Winter BB 46.86 12.79 151.53 21.60 72.13 345
Winter UK 43.10 11.35 202.57 20.72 65.47 34
Winter MK 55.50 11.12 189.71 33.57 77.43 45
Winter LK 27.84 10.05 130.68 7.96 47.73 34
Spring BB -90.97 12.23 126.78 -115.16 -66.77 1
Spring UK -125.12 10.71 166.46 -146.26 -103.98 1
Spring MK -130.41 9.28 97.73 -148.83 -111.98 1
Spring LK -131.64 9.18 93.55 -149.86 -113.42 1
Summer BB -10.42 13.12 166.46 -36.31 15.48 23
Summer UK -25.40 10.71 166.46 -46.55 -4.26 2
Summer MK -122.39 10.91 177.35 -143.91 -100.86 1
Summer LK -112.23 11.58 218.92 -135.06 -89.40 1
Fall BB 73.29 11.72 109.74 50.06 96.52 45
Fall UK 96.30 10.71 166.46 75.16 117.44 5
Fall MK 50.25 9.77 118.03 30.92 69.59 45
Fall LK -7.47 9.39 102.32 -26.10 11.16 23
  dDIC_year.emmc<-emmeans(dDIC_season, ~Sub_region*Zone)
    dDIC_year.emmc<-multcomp::cld(dDIC_year.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dDIC_year.emmc<-dDIC_year.emmc[order(dDIC_year.emmc$Zone, 
                                      dDIC_year.emmc$Sub_region), ]
  #dDIC_year.emmc
  
  dDIC_year.emmc[,-c(2)] %>% kable("html", digits=2, row.names = F,
                                  caption = "Year dDIC") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 4) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 5, 8) %>%
      pack_rows(., "Inshore", 9, 12)
Year dDIC
Sub_region emmean SE df lower.CL upper.CL .group
Offshore
BB 1.94 7.69 20.95 -14.06 17.93 3
UK -0.46 6.47 23.60 -13.82 12.90 3
MK -6.43 6.24 20.49 -19.42 6.56 23
LK 0.69 5.42 20.64 -10.59 11.97 3
Mid-Channel
BB 3.73 7.84 22.67 -12.50 19.96 3
UK -3.64 7.98 24.37 -20.10 12.83 23
MK -19.65 6.24 20.50 -32.64 -6.65 23
LK -18.61 6.15 19.32 -31.47 -5.76 23
Inshore
BB 4.69 7.67 20.71 -11.27 20.65 3
UK -2.78 6.54 24.73 -16.26 10.70 3
MK -36.76 6.30 21.34 -49.85 -23.67 12
LK -55.87 6.22 20.24 -68.84 -42.91 1

Figure 4B: Model

dDIC_ses_2.emmc<-as.data.frame(dDIC_ses.emmc)
dDIC_ye_3.emmc<-as.data.frame(dDIC_year.emmc)
dDIC_ye_3.emmc$Season<-"Mean"

dDIC_all_4<-rbind(dDIC_ses_2.emmc, dDIC_ye_3.emmc)
dDIC_all_4$Zone<-factor(dDIC_all_4$Zone, 
                          levels=c("Inshore" , "Mid channel", "Offshore"))


DeltaYearDIC<- ggplot(dDIC_all_4, aes(x=Season, y=emmean, fill=Sub_region)) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))+

    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.03, 0.03),
                     #breaks = seq(-800, 800, 50),
                     name=expression(paste(Delta, "DIC  (", mu, "mol ", ~kg^-1, ")")))+
    geom_bar(position = "dodge", color="black", 
           stat = "summary",
           fun = "mean")+
  geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE), width=0.2,
                 position=position_dodge(.9)) 
DeltaYearDIC

LMER - dDIC Inshore

# Inshore dDIC
  hist(inshore.season.data$dDIC_MY)

  shapiro.test(inshore.season.data$dDIC_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$dDIC_MY
## W = 0.99486, p-value = 0.2191
  dDIC_season_in<-lmer(dDIC_MY~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
  #summary(dDIC_season_in)    
  av.dDIC_season_in<-anova(dDIC_season_in)
  av.dDIC_season_in
  ranova(dDIC_season_in)
  #step(dDIC_season_in)
  
  plot(dDIC_season_in)

    par(mfrow=c(1,2))
    qqnorm(resid(dDIC_season_in))
    acf(resid(dDIC_season_in), main="acf(resid(dTA Season))")

    par(mfrow=c(1,1))
    #summ(dDIC_season_in, scale = TRUE)
    #plot_summs(dDIC_season_in)
  
  dDIC_ses_in.emmc<-emmeans(dDIC_season_in, ~ Sub_region*Season)
    dDIC_ses_in.emmc<-multcomp::cld(dDIC_ses_in.emmc)
    #dDIC_ses_in.emmc<-as.data.frame(dDIC_ses_in.emmc[complete.cases(dDIC_ses_in.emmc),])
    dDIC_ses_in.emmc<-dDIC_ses_in.emmc[order(dDIC_ses_in.emmc$Season,
                                           dDIC_ses_in.emmc$Sub_region), ]
  dDIC_ses_in.emmc

LMER - all dpCO2

# Inshore Omega
  hist(season.data$dpCO2_MY)

  shapiro.test(season.data$dpCO2_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dpCO2_MY
## W = 0.91489, p-value < 2.2e-16
  # dpCO2_season<-lmer(dpCO2_MY~ Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  dpCO2_season<-lmer(dpCO2_MY~ Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dpCO2_season)    
  av.dPCO2_season<-anova(dpCO2_season)
  av.dPCO2_season
  ranova(dpCO2_season)
  step(dpCO2_season)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik   AIC    LRT Df Pr(>Chisq)  
## <none>                    50 -6083.0 12266                       
## (1 | SiteID)          0   49 -6086.3 12271 6.5586  1    0.01044 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                        Eliminated Sum Sq Mean Sq NumDF   DenDF F value
## Zone:Sub_region:Season          1  64511    3584    18 1109.73  1.4821
## Zone:Sub_region                 2  15206    2534     6   21.57  1.0401
## Zone:Season                     0 610146  101691     6 1129.41 41.7412
## Sub_region:Season               0  69763    7751     9 1128.46  3.1818
##                           Pr(>F)    
## Zone:Sub_region:Season 0.0877942 .  
## Zone:Sub_region        0.4272177    
## Zone:Season            < 2.2e-16 ***
## Sub_region:Season      0.0008284 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dpCO2_MY ~ Zone + Sub_region + Season + (1 | SiteID) + Zone:Season + Sub_region:Season
  plot(dpCO2_season)

    par(mfrow=c(1,2))
    qqnorm(resid(dpCO2_season))
    acf(resid(dpCO2_season), main="acf(resid(dTA Season))")

    par(mfrow=c(1,1))
    #plot_summs(dpCO2_season)  
  
  dpCO2_ses.emmc<-emmeans(dpCO2_season, ~Zone*Sub_region*Season)
    dpCO2_ses.emmc<-multcomp::cld(dpCO2_ses.emmc)
    #dpCO2_ses.emmc<-as.data.frame(dpCO2_ses.emmc[complete.cases(dpCO2_ses.emmc),])
    dpCO2_ses.emmc<-dpCO2_ses.emmc[order(dpCO2_ses.emmc$Zone, dpCO2_ses.emmc$Season), ]
  dpCO2_ses.emmc
  #summ(dpCO2_season, scale = TRUE)

LMER - dpCO2 Inshore

# Inshore dDIC
  hist(inshore.season.data$dpCO2_MY)

  shapiro.test(inshore.season.data$dpCO2_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$dpCO2_MY
## W = 0.98334, p-value = 0.0001773
  dpCO2_season_in<-lmer(dpCO2_MY~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
  #summary(dpCO2_season_in)    
  av.dPCO2_season_in<-anova(dpCO2_season_in)
  av.dPCO2_season_in
  ranova(dpCO2_season_in)
  #step(dpCO2_season_in)
  
  plot(dpCO2_season_in)

    par(mfrow=c(1,2))
    qqnorm(resid(dpCO2_season_in))
    acf(resid(dpCO2_season_in), main="acf(resid(dTA Season))")

    par(mfrow=c(1,1))
    #summ(dpCO2_season_in, scale = TRUE)
    #plot_summs(dpCO2_season_in)
  
  dpCO2_ses_in.emmc<-emmeans(dpCO2_season_in, ~ Sub_region*Season)
    dpCO2_ses_in.emmc<-multcomp::cld(dpCO2_ses_in.emmc)
    #dpCO2_ses_in.emmc<-as.data.frame(dpCO2_ses_in.emmc[complete.cases(dpCO2_ses_in.emmc),])
    dpCO2_ses_in.emmc<-dpCO2_ses_in.emmc[order(dpCO2_ses_in.emmc$Season,
                                           dpCO2_ses_in.emmc$Sub_region), ]
  dpCO2_ses_in.emmc

LMER - all Omega

# Inshore Omega
  hist(season.data$Aragonite_Sat_W)

  shapiro.test(season.data$Aragonite_Sat_W) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$Aragonite_Sat_W
## W = 0.97667, p-value = 6.107e-13
  # Omega_season<-lmer(Aragonite_Sat_W~  Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  Omega_season<-lmer(Aragonite_Sat_W~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(Omega_season)    
  av.Ome_season<-anova(Omega_season)
  av.Ome_season
  ranova(Omega_season)
  #step(Omega_season)
  
  plot(Omega_season)

    par(mfrow=c(1,2))
    qqnorm(resid(Omega_season))
    acf(resid(Omega_season), main="acf(resid(dTA Season))")

    par(mfrow=c(1,1))
    #plot_summs(Omega_season)  
    
  # Ara_ses.emmc<-emmeans(Omega_season, ~Zone*Sub_region*Season)
  #   Ara_ses.emmc<-multcomp::cld(Ara_ses.emmc)
  #   Ara_ses.emmc<-as.data.frame(Ara_ses.emmc[complete.cases(Ara_ses.emmc),])
  #   Ara_ses.emmc<-Ara_ses.emmc[order(Ara_ses.emmc$Zone, Ara_ses.emmc$Season), ]
  # Ara_ses.emmc
  
  Ara_ses.emmc<-emmeans(Omega_season, ~Zone*Season, by="Sub_region")
    Ara_ses.emmc<-multcomp::cld(Ara_ses.emmc)
    Ara_ses.emmc
  Ara_ses.emmc2<-emmeans(Omega_season, ~Sub_region*Season, by="Zone")
    Ara_ses.emmc2<-multcomp::cld(Ara_ses.emmc2)
    Ara_ses.emmc2

LMER - all dOmega - MODEL 16

# Inshore Omega
  hist(season.data$dOme_MY)

  shapiro.test(season.data$dOme_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dOme_MY
## W = 0.94836, p-value < 2.2e-16
  # Omega_season<-lmer(Aragonite_Sat_W~  Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  dOmega_season<-lmer(dOme_MY~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dOmega_season)    
  av.dOme_season<-anova(dOmega_season)
  av.dOme_season
  ranova(dOmega_season)
  #step(dOmega_season)
  
  plot(dOmega_season)

    par(mfrow=c(1,2))
    qqnorm(resid(dOmega_season))
    acf(resid(dOmega_season), main="acf(resid(dTA Season))")

    par(mfrow=c(1,1))
    #plot_summs(dOmega_season)  
    
dAra_ses.emmc<-emmeans(dOmega_season, ~Zone*Season, by="Sub_region")
    dAra_ses.emmc<-multcomp::cld(dAra_ses.emmc)
    dAra_ses.emmc
dAra_ses.emmc1<-emmeans(dOmega_season, ~Sub_region*Season, by="Zone")
    dAra_ses.emmc1<-multcomp::cld(dAra_ses.emmc1)
    dAra_ses.emmc1
dAra_ses.emmc2<-emmeans(dOmega_season, ~Season*Sub_region, by="Zone")
    dAra_ses.emmc2<-multcomp::cld(dAra_ses.emmc2)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dAra_ses.emmc2<-dAra_ses.emmc2[order(dAra_ses.emmc2$Zone, 
                                     dAra_ses.emmc2$Season, 
                                     dAra_ses.emmc2$Sub_region), ]

dAra_ses.emmc2[,-c(3)] %>% kable("html", digits=2, row.names = F,
                                 caption = "Seasonal d Omega") %>%
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 16) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 17, 32) %>%
      pack_rows(., "Inshore", 33, 48)
Seasonal d Omega
Season Sub_region emmean SE df lower.CL upper.CL .group
Offshore
Winter BB 0.02 0.07 188.90 -0.12 0.16 1
Winter UK 0.04 0.06 218.36 -0.08 0.16 1
Winter MK -0.04 0.06 194.94 -0.16 0.07 1
Winter LK -0.07 0.05 187.22 -0.17 0.03 1
Spring BB -0.04 0.07 156.03 -0.17 0.10 1
Spring UK -0.01 0.06 182.03 -0.12 0.11 1
Spring MK 0.06 0.05 138.40 -0.05 0.17 1
Spring LK -0.06 0.05 134.05 -0.16 0.03 1
Summer BB -0.13 0.07 208.26 -0.27 0.02 1
Summer UK -0.03 0.06 235.49 -0.15 0.10 1
Summer MK -0.07 0.06 208.26 -0.19 0.05 1
Summer LK -0.15 0.05 241.97 -0.26 -0.04 1
Fall BB -0.05 0.07 145.13 -0.18 0.08 1
Fall UK -0.04 0.06 183.21 -0.15 0.08 1
Fall MK -0.02 0.05 138.40 -0.13 0.09 1
Fall LK -0.06 0.05 139.79 -0.15 0.04 1
Mid-Channel
Winter BB -0.04 0.07 208.26 -0.19 0.10 12345
Winter UK 0.08 0.08 229.47 -0.07 0.23 2345
Winter MK 0.00 0.06 194.94 -0.12 0.11 234
Winter LK -0.19 0.05 145.50 -0.30 -0.08 12
Spring BB 0.13 0.07 206.04 -0.01 0.28 345
Spring UK 0.27 0.07 188.86 0.13 0.41 45
Spring MK 0.27 0.05 131.50 0.17 0.38 5
Spring LK 0.02 0.05 119.26 -0.09 0.12 2345
Summer BB -0.21 0.07 208.26 -0.36 -0.07 12
Summer UK -0.03 0.08 252.17 -0.18 0.13 12345
Summer MK -0.20 0.06 208.26 -0.32 -0.08 123
Summer LK -0.32 0.06 237.70 -0.44 -0.19 1
Fall BB -0.20 0.07 158.32 -0.34 -0.07 12
Fall UK -0.17 0.07 188.86 -0.31 -0.02 123
Fall MK -0.17 0.05 146.09 -0.28 -0.06 123
Fall LK -0.19 0.05 125.28 -0.29 -0.09 12
Inshore
Winter BB -0.06 0.07 188.91 -0.20 0.08 567
Winter UK 0.05 0.06 253.35 -0.08 0.17 67
Winter MK 0.03 0.06 237.66 -0.10 0.15 67
Winter LK -0.24 0.06 161.40 -0.35 -0.13 3456
Spring BB 0.24 0.07 156.06 0.11 0.38 78
Spring UK 0.65 0.06 208.26 0.53 0.77 9
Spring MK 0.44 0.05 119.25 0.34 0.55 89
Spring LK -0.01 0.05 113.80 -0.11 0.09 67
Summer BB -0.41 0.07 208.26 -0.55 -0.26 234
Summer UK -0.12 0.06 208.26 -0.24 0.00 456
Summer MK -0.41 0.06 221.97 -0.53 -0.29 234
Summer LK -0.80 0.07 274.41 -0.93 -0.67 1
Fall BB -0.48 0.07 134.85 -0.61 -0.35 123
Fall UK -0.52 0.06 208.26 -0.64 -0.40 123
Fall MK -0.35 0.05 145.46 -0.46 -0.24 345
Fall LK -0.65 0.05 125.28 -0.75 -0.54 12
dOm_year.emmc<-emmeans(dOmega_season, ~Sub_region*Zone)
    dOm_year.emmc<-multcomp::cld(dOm_year.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dOm_year.emmc<-dOm_year.emmc[order(dOm_year.emmc$Zone, 
                                      dOm_year.emmc$Sub_region), ]
  #dDIC_year.emmc
  
  dOm_year.emmc[,-c(2)] %>% kable("html", digits=2, row.names = F,
                                  caption = "Year d Omega") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 4) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 5, 8) %>%
      pack_rows(., "Inshore", 9, 12)
Year d Omega
Sub_region emmean SE df lower.CL upper.CL .group
Offshore
BB -0.05 0.04 20.88 -0.13 0.04 234
UK -0.01 0.03 24.10 -0.08 0.06 234
MK -0.02 0.03 20.35 -0.09 0.05 234
LK -0.08 0.03 20.92 -0.14 -0.02 234
Mid-Channel
BB -0.08 0.04 22.98 -0.17 0.01 234
UK 0.04 0.04 25.04 -0.05 0.13 4
MK -0.02 0.03 20.37 -0.09 0.04 234
LK -0.17 0.03 18.97 -0.24 -0.10 2
Inshore
BB -0.18 0.04 20.60 -0.26 -0.09 23
UK 0.01 0.03 25.50 -0.06 0.09 34
MK -0.07 0.03 21.38 -0.14 0.00 234
LK -0.42 0.03 20.05 -0.49 -0.36 1

Figure 4D: Model

dAra_ses_2.emmc<-as.data.frame(dAra_ses.emmc2)
dAra_ye_3.emmc<-as.data.frame(dOm_year.emmc)
dAra_ye_3.emmc$Season<-"Mean"

dAra_all_4<-rbind(dAra_ses_2.emmc, dAra_ye_3.emmc)
dAra_all_4$Zone<-factor(dDIC_all_4$Zone, 
                          levels=c("Inshore" , "Mid channel", "Offshore"))

DeltaYearAra<- ggplot(dAra_all_4, aes(x=Season, y=emmean, fill=Sub_region)) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))+

    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.03, 0.03),
                     breaks = seq(-6, 6, 0.3),
                     name=(expression (paste(Delta ,
                          ~Omega[Ar]))))+
    geom_bar(position = "dodge", color="black", 
           stat = "summary",
           fun = "mean")+
    geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE), width=0.2,
                 position=position_dodge(.9)) 

DeltaYearAra

LMER - Omega Inshore

# Inshore dOmega
  hist(inshore.season.data$Aragonite_Sat_W)

  shapiro.test(inshore.season.data$Aragonite_Sat_W) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$Aragonite_Sat_W
## W = 0.9897, p-value = 0.006908
  Omega_season_in<-lmer(Aragonite_Sat_W~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
      #summary(Omega_season_in)    
      av.Ome_season_in<-anova(Omega_season_in)
      av.Ome_season_in
      ranova(Omega_season_in)
      #step(Omega_season_in)
      
    plot(Omega_season_in)

      par(mfrow=c(1,2))
      qqnorm(resid(Omega_season_in))
      acf(resid(Omega_season_in), main="acf(resid(dTA Season))")

      par(mfrow=c(1,1))
      #summ(dDIC_season_in, scale = TRUE)
  #plot_summs(Omega_season_in)
  
  omega_ses_in.emmc<-emmeans(Omega_season_in, ~ Sub_region*Season)
    omega_ses_in.emmc<-multcomp::cld(omega_ses_in.emmc)
    #omega_ses_in.emmc<-as.data.frame(omega_ses_in.emmc[complete.cases(omega_ses_in.emmc),])
    omega_ses_in.emmc<-omega_ses_in.emmc[order(omega_ses_in.emmc$Season,
                                           omega_ses_in.emmc$Sub_region), ]
  omega_ses_in.emmc

LMER - all pH

# Inshore Omega
  hist(season.data$pH_calculated)

  shapiro.test(season.data$pH_calculated) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$pH_calculated
## W = 0.97823, p-value = 2.099e-12
  # pH_season<-lmer(pH_calculated~ Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  pH_season<-lmer(pH_calculated~ Zone * Sub_region * Season *
                           (1|SiteID), data=season.data)
  
        #summary(pH_season)    
        av.pH_season<-anova(pH_season)
        av.pH_season
        ranova(pH_season)
        #step(pH_season)
        
        plot(pH_season)

        par(mfrow=c(1,2))
        qqnorm(resid(pH_season))
        acf(resid(pH_season), main="acf(resid(dTA Season))")

        par(mfrow=c(1,1))
  #summ(pH_season, scale = TRUE)
  #plot_summs(pH_season)  
  
  pH_ses.emmc<-emmeans(pH_season, ~Zone*Sub_region*Season)
    pH_ses.emmc<-multcomp::cld(pH_ses.emmc)
    pH_ses.emmc<-as.data.frame(pH_ses.emmc[complete.cases(pH_ses.emmc),])
    pH_ses.emmc<-pH_ses.emmc[order(pH_ses.emmc$Zone, pH_ses.emmc$Season), ]
  pH_ses.emmc
  pH_ses.emmc<-emmeans(pH_season, ~Zone, by = "Sub_region")
    pH_ses.emmc<-multcomp::cld(pH_ses.emmc)
    pH_ses.emmc<-as.data.frame(pH_ses.emmc[complete.cases(pH_ses.emmc),])
    #pH_ses.emmc<-pH_ses.emmc[order(pH_ses.emmc$Zone, pH_ses.emmc$Season), ]
  pH_ses.emmc
  pH_ses.emmc<-emmeans(pH_season, ~Zone)
    pH_ses.emmc<-multcomp::cld(pH_ses.emmc)
    pH_ses.emmc<-as.data.frame(pH_ses.emmc[complete.cases(pH_ses.emmc),])
    #pH_ses.emmc<-pH_ses.emmc[order(pH_ses.emmc$Zone, pH_ses.emmc$Season), ]
  pH_ses.emmc

LMER - all dpH - MODEL 15

# Inshore Omega
  hist(season.data$dpH_MY)

  shapiro.test(season.data$dpH_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dpH_MY
## W = 0.93766, p-value < 2.2e-16
  # dpH_season<-lmer(Aragonite_Sat_W~  Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  dpH_season<-lmer(dpH_MY~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dpH_season)    
  av.dpH_season<-anova(dpH_season)
  av.dpH_season
  ranova(dpH_season)
  #step(dpH_season)
  
  plot(dpH_season)

    par(mfrow=c(1,2))
    qqnorm(resid(dpH_season))
    acf(resid(dpH_season), main="acf(resid(dTA Season))")

    par(mfrow=c(1,1))
    #plot_summs(dpH_season)  
    
dpH_ses.emmc<-emmeans(dpH_season, ~Zone*Season, by="Sub_region")
    dpH_ses.emmc<-multcomp::cld(dpH_ses.emmc)
    dpH_ses.emmc
dpH_ses.emmc<-emmeans(dpH_season, ~Sub_region)
    dpH_ses.emmc<-multcomp::cld(dpH_ses.emmc)
    dpH_ses.emmc
dpH_ses.emmc2<-emmeans(dpH_season, ~Season*Sub_region, by="Zone")
    dpH_ses.emmc2<-multcomp::cld(dpH_ses.emmc2)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dpH_ses.emmc2<-dpH_ses.emmc2[order(dpH_ses.emmc2$Zone, 
                                     dpH_ses.emmc2$Season, 
                                     dpH_ses.emmc2$Sub_region), ]
  #dpH_ses.emmc2

  dpH_ses.emmc2[,-c(3)] %>% kable("html", digits=2, row.names = F,
                                   caption = "Seasonal d pH") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 16) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 17, 32) %>%
      pack_rows(., "Inshore", 33, 48)
Seasonal d pH
Season Sub_region emmean SE df lower.CL upper.CL .group
Offshore
Winter BB 0.01 0.01 145.67 -0.01 0.03 1
Winter UK 0.01 0.01 168.69 -0.01 0.03 1
Winter MK 0.00 0.01 150.14 -0.01 0.02 1
Winter LK 0.00 0.01 144.97 -0.02 0.01 1
Spring BB 0.00 0.01 122.12 -0.02 0.02 1
Spring UK 0.00 0.01 140.91 -0.02 0.02 1
Spring MK 0.01 0.01 108.39 -0.01 0.03 1
Spring LK -0.01 0.01 105.48 -0.02 0.01 1
Summer BB -0.02 0.01 159.91 -0.04 0.00 1
Summer UK -0.01 0.01 181.14 -0.03 0.01 1
Summer MK -0.01 0.01 159.91 -0.03 0.01 1
Summer LK -0.02 0.01 185.37 -0.04 0.00 1
Fall BB 0.00 0.01 113.58 -0.02 0.02 1
Fall UK 0.00 0.01 141.43 -0.02 0.02 1
Fall MK 0.00 0.01 108.39 -0.01 0.02 1
Fall LK 0.00 0.01 109.55 -0.02 0.01 1
Mid-Channel
Winter BB 0.01 0.01 159.91 -0.01 0.03 123456
Winter UK 0.03 0.01 176.00 0.00 0.05 3456
Winter MK 0.01 0.01 150.14 0.00 0.03 3456
Winter LK -0.01 0.01 113.74 -0.03 0.00 12345
Spring BB 0.02 0.01 158.94 0.00 0.05 456
Spring UK 0.03 0.01 145.64 0.01 0.06 56
Spring MK 0.04 0.01 103.33 0.02 0.05 6
Spring LK 0.01 0.01 94.36 -0.01 0.02 23456
Summer BB -0.03 0.01 159.91 -0.05 -0.01 123
Summer UK -0.01 0.01 193.98 -0.04 0.01 12345
Summer MK -0.03 0.01 159.91 -0.05 -0.01 12
Summer LK -0.04 0.01 182.17 -0.06 -0.02 1
Fall BB -0.02 0.01 123.05 -0.04 0.00 12345
Fall UK -0.01 0.01 145.64 -0.04 0.01 12345
Fall MK -0.01 0.01 113.97 -0.03 0.01 12345
Fall LK -0.02 0.01 98.72 -0.03 0.00 1234
Inshore
Winter BB 0.01 0.01 145.67 -0.01 0.04 456
Winter UK 0.03 0.01 194.52 0.02 0.05 567
Winter MK 0.02 0.01 182.15 0.00 0.04 56
Winter LK -0.01 0.01 125.83 -0.03 0.01 345
Spring BB 0.05 0.01 122.14 0.03 0.07 678
Spring UK 0.10 0.01 159.91 0.08 0.11 8
Spring MK 0.07 0.01 94.35 0.05 0.08 78
Spring LK 0.02 0.01 90.36 0.00 0.03 56
Summer BB -0.06 0.01 159.91 -0.08 -0.04 12
Summer UK -0.03 0.01 159.91 -0.05 -0.01 234
Summer MK -0.05 0.01 170.33 -0.07 -0.03 23
Summer LK -0.10 0.01 210.11 -0.12 -0.08 1
Fall BB -0.05 0.01 105.80 -0.07 -0.03 23
Fall UK -0.06 0.01 159.91 -0.08 -0.05 12
Fall MK -0.03 0.01 113.72 -0.05 -0.01 234
Fall LK -0.06 0.01 98.72 -0.07 -0.04 2
  dpH_year.emmc<-emmeans(dpH_season, ~Sub_region*Zone)
    dpH_year.emmc<-multcomp::cld(dpH_year.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dpH_year.emmc<-dpH_year.emmc[order(dpH_year.emmc$Zone, 
                                      dpH_year.emmc$Sub_region), ]
  #dDIC_year.emmc
  
  dpH_year.emmc[,-c(2)] %>% kable("html", digits=2, row.names = F,
                                  caption = "Year d pH") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 4) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 5, 8) %>%
      pack_rows(., "Inshore", 9, 12)
Year d pH
Sub_region emmean SE df lower.CL upper.CL .group
Offshore
BB 0.00 0.01 20.91 -0.02 0.01 2
UK 0.00 0.01 23.46 -0.01 0.01 2
MK 0.00 0.01 20.45 -0.01 0.01 2
LK -0.01 0.00 20.94 -0.02 0.00 2
Mid-Channel
BB 0.00 0.01 22.56 -0.02 0.01 2
UK 0.01 0.01 24.20 -0.01 0.02 2
MK 0.00 0.01 20.46 -0.01 0.01 2
LK -0.02 0.01 19.33 -0.03 -0.01 12
Inshore
BB -0.01 0.01 20.68 -0.03 0.00 12
UK 0.01 0.01 24.55 0.00 0.02 2
MK 0.00 0.01 21.28 -0.01 0.01 2
LK -0.04 0.01 20.22 -0.05 -0.03 1

Figure 4C: Model

dpH_ses_2.emmc<-as.data.frame(dpH_ses.emmc2)
dpH_ye_3.emmc<-as.data.frame(dpH_year.emmc)
dpH_ye_3.emmc$Season<-"Mean"

dpH_all_4<-rbind(dpH_ses_2.emmc, dpH_ye_3.emmc)
dpH_all_4$Zone<-factor(dDIC_all_4$Zone, 
                          levels=c("Inshore" , "Mid channel", "Offshore"))


DeltaYearpH<- ggplot(dpH_all_4, aes(x=Season, y=emmean, fill=Sub_region)) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))+

    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.01, 0.01),
                     breaks = seq(-6, 6, 0.05),
                     name=(expression (paste(Delta ,
                          ~pH[]))))+
    geom_bar(position = "dodge", color="black", 
           stat = "summary",
           fun = "mean")+
    geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE), width=0.2,
                 position=position_dodge(.9)) 
DeltaYearpH

LMER - pH Inshore

# Inshore pH
  hist(inshore.season.data$pH_calculated)

  shapiro.test(inshore.season.data$pH_calculated) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$pH_calculated
## W = 0.99421, p-value = 0.1375
  pH_season_in<-lmer(pH_calculated~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
    #summary(pH_season_in)    
    av.pH_season_in<-anova(pH_season_in)
    av.pH_season_in
    ranova(pH_season_in)
    #step(pH_season_in)
    
    plot(pH_season_in)

      par(mfrow=c(1,2))
      qqnorm(resid(pH_season_in))
      acf(resid(pH_season_in), main="acf(resid(dTA Season))")

      par(mfrow=c(1,1))
      #summ(pH_season_in, scale = TRUE)
      #plot_summs(pH_season_in)
  
  pH_ses_in.emmc<-emmeans(pH_season_in, ~ Sub_region*Season)
    pH_ses_in.emmc<-multcomp::cld(pH_ses_in.emmc)
    #pH_ses_in.emmc<-as.data.frame(pH_ses_in.emmc[complete.cases(pH_ses_in.emmc),])
    pH_ses_in.emmc<-pH_ses_in.emmc[order(pH_ses_in.emmc$Season,
                                           pH_ses_in.emmc$Sub_region), ]
  pH_ses_in.emmc

Summary all data

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.dTA_season <- data.frame(av.dTA_season)
    av.dDIC_season <- data.frame(av.dDIC_season) 
    av.dPCO2_season <- data.frame(av.dPCO2_season)
    av.dOme_season <- data.frame(av.dOme_season) 
    av.dpH_season <- data.frame(av.dpH_season) 
    
    # Putting all into one dataframe/table
    anova_results_all <- data.frame(cbind
                    (c("Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season",
                       
                       "Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season",
                       
                       "Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season",
                       
                       "Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season",
                       
                       "Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season"), 
                                      rbind(av.dTA_season, av.dDIC_season, av.dPCO2_season,
                                            av.dOme_season, av.dpH_season ))) 
    colnames(anova_results_all) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_results_all) <- NULL
    
    # create HTML table using kableExtra
    anova_results_all %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "d TA", 1, 7) %>% # groups rows with label
      pack_rows(., "d DIC", 8, 14)  %>% # groups rows with label
      pack_rows(., "d pCO2", 15, 21) %>% # groups rows with label
      pack_rows(., "d Omega", 22, 28)  %>% # groups rows with label
      pack_rows(., "d pH", 29, 35)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
d TA
Zone 147511.18 73755.59 2 24.33 33.83 0.00
Sub_region 255038.82 85012.94 3 24.08 39.00 0.00
Season 857202.03 285734.01 3 1118.93 131.07 0.00
Zone:Sub_region 194809.81 32468.30 6 24.08 14.89 0.00
Zone:Season 564721.55 94120.26 6 1118.94 43.17 0.00
Sub_region:Season 161239.24 17915.47 9 1118.88 8.22 0.00
Zone:Sub_region:Season 85053.62 4725.20 18 1118.89 2.17 0.00
d DIC
Zone 50385.20 25192.60 2 23.49 10.81 0.00
Sub_region 85646.72 28548.91 3 23.38 12.25 0.00
Season 1361232.88 453744.29 3 1113.08 194.76 0.00
Zone:Sub_region 65760.45 10960.07 6 23.37 4.70 0.00
Zone:Season 1013441.05 168906.84 6 1113.08 72.50 0.00
Sub_region:Season 174759.19 19417.69 9 1113.05 8.33 0.00
Zone:Sub_region:Season 102157.02 5675.39 18 1113.06 2.44 0.00
d pCO2
Zone 16149.26 8074.63 2 21.97 3.34 0.05
Sub_region 62914.07 20971.36 3 21.87 8.67 0.00
Season 908279.53 302759.84 3 1109.76 125.20 0.00
Zone:Sub_region 17081.00 2846.83 6 21.87 1.18 0.35
Zone:Season 618840.71 103140.12 6 1109.76 42.65 0.00
Sub_region:Season 70185.63 7798.40 9 1109.73 3.22 0.00
Zone:Sub_region:Season 64511.25 3583.96 18 1109.73 1.48 0.09
d Omega
Zone 2.27 1.14 2 21.43 14.50 0.00
Sub_region 6.84 2.28 3 21.29 29.06 0.00
Season 32.27 10.76 3 1109.53 137.17 0.00
Zone:Sub_region 2.86 0.48 6 21.29 6.08 0.00
Zone:Season 20.30 3.38 6 1109.54 43.15 0.00
Sub_region:Season 2.60 0.29 9 1109.49 3.68 0.00
Zone:Sub_region:Season 1.93 0.11 18 1109.50 1.37 0.14
d pH
Zone 0.01 0.00 2 22.29 1.91 0.17
Sub_region 0.07 0.02 3 22.19 14.15 0.00
Season 0.68 0.23 3 1110.09 132.93 0.00
Zone:Sub_region 0.03 0.00 6 22.19 2.73 0.04
Zone:Season 0.40 0.07 6 1110.10 39.14 0.00
Sub_region:Season 0.04 0.00 9 1110.06 2.74 0.00
Zone:Sub_region:Season 0.04 0.00 18 1110.07 1.22 0.24
#export_summs(dTA_season, dDIC_season, dpCO2_season,  scale = TRUE)
      
      Seasonal_models<-list("d TA" = dTA_season, 
                         "d DIC" = dDIC_season, 
                         "d pCO2" = dpCO2_season, 
                         "Omega" = Omega_season,
                         "pH" = pH_season)
      
      modelsummary(Seasonal_models, stars = TRUE, 
                   #statistic = c('std.error', 'p.value', 'conf.int'),
                   title = 'Seasonal and spatial models'#,
                   #coef_map=factor_order
                   )
Seasonal and spatial models
d TA d DIC d pCO2 Omega pH
(Intercept) 1.046 −1.154 −7.599 3.699*** 8.074***
(11.744) (12.788) (13.287) (0.071) (0.012)
ZoneMid channel 6.972 11.804 1.346 −0.061 −0.002
(16.848) (18.319) (19.024) (0.101) (0.017)
ZoneInshore 39.553* 48.017** 4.049 −0.083 0.006
(16.609) (18.085) (18.791) (0.100) (0.016)
Sub_regionUK 2.844 1.067 −1.212 −0.009 −0.003
(15.469) (16.815) (17.460) (0.093) (0.015)
Sub_regionMK 3.549 9.085 5.807 −0.057 −0.004
(15.218) (16.565) (17.209) (0.091) (0.015)
Sub_regionLK 0.897 8.471 9.595 −0.110 −0.010
(14.386) (15.544) (16.277) (0.086) (0.014)
SeasonSpring −4.947 0.623 9.927 0.056 −0.036*
(15.590) (16.118) (16.422) (0.089) (0.015)
SeasonSummer −6.558 7.034 33.200+ 0.178+ −0.075***
(16.264) (16.814) (17.130) (0.095) (0.016)
SeasonFall −1.881 4.705 12.232 0.059 −0.035*
(15.403) (15.923) (16.223) (0.090) (0.015)
ZoneMid channelSub_regionUK −0.203 −9.981 −15.883 0.121 0.020
(23.243) (25.231) (26.187) (0.139) (0.023)
ZoneInshoreSub_regionUK 5.298 −4.833 −18.158 0.105 0.020
(22.080) (23.979) (24.890) (0.133) (0.022)
ZoneMid channelSub_regionMK 13.672 4.725 −6.314 0.118 0.014
(21.706) (23.607) (24.518) (0.130) (0.022)
ZoneInshoreSub_regionMK 12.850 −0.447 −11.098 0.157 0.014
(21.796) (23.696) (24.607) (0.131) (0.022)
ZoneMid channelSub_regionLK 4.635 12.672 18.773 −0.036 −0.007
(20.785) (22.561) (23.534) (0.125) (0.021)
ZoneInshoreSub_regionLK −34.138+ −27.489 12.904 −0.069 −0.011
(20.719) (22.498) (23.471) (0.125) (0.021)
ZoneMid channelSeasonSpring −11.688 −33.176 −31.337 0.215+ 0.031
(22.708) (23.479) (23.921) (0.129) (0.022)
ZoneInshoreSeasonSpring −98.226*** −138.451*** −67.932** 0.398** 0.048*
(22.048) (22.795) (23.224) (0.125) (0.021)
ZoneMid channelSeasonSummer −15.240 −13.658 7.610 −0.021 −0.007
(23.174) (23.957) (24.407) (0.135) (0.023)
ZoneInshoreSeasonSummer −80.288*** −64.312** 48.003* −0.196 −0.047*
(23.001) (23.778) (24.225) (0.134) (0.022)
ZoneMid channelSeasonFall −2.072 6.809 17.624 −0.088 −0.013
(22.097) (22.843) (23.273) (0.129) (0.021)
ZoneInshoreSeasonFall −12.472 21.724 69.956** −0.357** −0.053*
(21.663) (22.395) (22.816) (0.126) (0.021)
Sub_regionUKSeasonSpring −0.927 −2.048 −1.717 0.044 0.004
(20.544) (21.247) (21.649) (0.118) (0.020)
Sub_regionMKSeasonSpring −7.109 −22.158 −21.626 0.161 0.019
(20.015) (20.693) (21.083) (0.114) (0.019)
Sub_regionLKSeasonSpring −8.497 −14.026 −4.731 0.079 0.003
(18.952) (19.499) (19.965) (0.109) (0.018)
Sub_regionUKSeasonSummer −2.100 −9.926 −12.532 0.114 0.013
(21.410) (22.134) (22.551) (0.125) (0.021)
Sub_regionMKSeasonSummer −22.755 −35.401 −25.781 0.119 0.015
(21.037) (21.748) (22.157) (0.122) (0.020)
Sub_regionLKSeasonSummer −5.819 −14.001 −12.088 0.102 0.011
(19.920) (20.685) (21.168) (0.117) (0.020)
Sub_regionUKSeasonFall −2.590 −1.883 −2.761 0.012 0.002
(20.395) (21.085) (21.482) (0.119) (0.020)
Sub_regionMKSeasonFall −4.033 −12.248 −12.350 0.085 0.012
(19.870) (20.542) (20.928) (0.116) (0.019)
Sub_regionLKSeasonFall −3.416 −10.847 −11.405 0.114 0.011
(18.830) (19.370) (19.833) (0.110) (0.018)
ZoneMid channelSub_regionUKSeasonSpring 3.876 3.803 9.623 0.013 −0.017
(31.118) (32.179) (32.787) (0.178) (0.030)
ZoneInshoreSub_regionUKSeasonSpring −1.712 −28.339 −22.426 0.260 0.030
(29.322) (30.322) (30.894) (0.167) (0.028)
ZoneMid channelSub_regionMKSeasonSpring −38.793 −35.462 1.763 −0.066 −0.019
(28.785) (29.760) (30.321) (0.164) (0.027)
ZoneInshoreSub_regionMKSeasonSpring −27.637 −25.920 4.822 −0.060 −0.008
(28.405) (29.367) (29.920) (0.162) (0.027)
ZoneMid channelSub_regionLKSeasonSpring −37.531 −38.693 −9.099 −0.022 −0.006
(27.725) (28.600) (29.207) (0.159) (0.026)
ZoneInshoreSub_regionLKSeasonSpring −20.178 −7.628 6.718 −0.174 −0.017
(27.248) (28.106) (28.704) (0.156) (0.026)
ZoneMid channelSub_regionUKSeasonSummer 7.655 11.814 10.293 −0.036 −0.013
(32.125) (33.211) (33.835) (0.187) (0.031)
ZoneInshoreSub_regionUKSeasonSummer 4.972 −1.293 −9.457 0.079 −0.001
(30.292) (31.317) (31.907) (0.176) (0.029)
ZoneMid channelSub_regionMKSeasonSummer −53.984+ −42.356 11.077 −0.163 −0.025
(29.885) (30.895) (31.476) (0.174) (0.029)
ZoneInshoreSub_regionMKSeasonSummer −96.163** −85.210** −17.181 −0.216 −0.012
(30.016) (31.031) (31.615) (0.175) (0.029)
ZoneMid channelSub_regionLKSeasonSummer −62.480* −68.959* −15.707 −0.053 −0.005
(28.859) (30.045) (30.675) (0.169) (0.028)
ZoneInshoreSub_regionLKSeasonSummer −98.607*** −68.791* 12.371 −0.299+ −0.027
(28.954) (30.172) (30.804) (0.170) (0.028)
ZoneMid channelSub_regionUKSeasonFall −3.487 4.409 14.884 −0.107 −0.017
(30.668) (31.705) (32.301) (0.178) (0.030)
ZoneInshoreSub_regionUKSeasonFall 12.622 28.658 44.740 −0.141 −0.029
(29.029) (30.012) (30.577) (0.169) (0.028)
ZoneMid channelSub_regionMKSeasonFall −10.085 −1.136 5.312 −0.117 −0.013
(28.385) (29.345) (29.897) (0.165) (0.028)
ZoneInshoreSub_regionMKSeasonFall −21.816 −19.427 −16.350 −0.045 0.003
(28.262) (29.218) (29.768) (0.164) (0.027)
ZoneMid channelSub_regionLKSeasonFall −17.841 −27.429 −21.551 0.047 0.010
(27.283) (28.139) (28.736) (0.159) (0.027)
ZoneInshoreSub_regionLKSeasonFall −52.807+ −50.897+ −24.516 −0.087 0.005
(27.030) (27.877) (28.471) (0.157) (0.026)
SD (Intercept SiteID) 4.397 7.272 8.276 0.036 0.005
SD (Observations) 46.691 48.267 49.175 0.272 0.045
Num.Obs. 1184 1179 1177 1191 1191
R2 Marg. 0.500 0.535 0.383 0.451 0.457
R2 Cond. 0.504 0.545 0.400 0.460 0.464
AIC 12214.1 12243.0 12266.0 527.1 −3564.8
BIC 12467.9 12496.6 12519.6 781.2 −3310.6
ICC 0.0 0.0 0.0 0.0 0.0
RMSE 45.63 47.08 47.94 0.27 0.04
+ p
      #modelsummary(Omega_models, estimate = "p.value")

Summary all inshore

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.dTA_season_in <- data.frame(av.dTA_season_in)
    av.dDIC_season_in <- data.frame(av.dDIC_season_in) 
    av.dPCO2_season_in <- data.frame(av.dPCO2_season_in)
    av.Ome_season_in <- data.frame(av.Ome_season_in) 
    av.pH_season_in <- data.frame(av.pH_season_in) 
    
    # Putting all into one dataframe/table
    anova_results_In <- data.frame(cbind
                    (c("Sub_region", "Season", "Sub_region:Season", 
                       
                       "Sub_region", "Season", "Sub_region:Season",
                       
                       "Sub_region", "Season", "Sub_region:Season",
                       
                       "Sub_region", "Season", "Sub_region:Season",
                       
                       "Sub_region", "Season", "Sub_region:Season"), 
                                      rbind(av.dTA_season_in, av.dDIC_season_in,
                                            av.dPCO2_season_in,
                                            av.Ome_season_in, av.pH_season_in))) 
    colnames(anova_results_In) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_results_In) <- NULL
    
    # create HTML table using kableExtra
    anova_results_In %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "d TA inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "d DIC inshore", 4, 6)  %>% # groups rows with label
      pack_rows(., "d pCO2 inshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega inshore", 10, 12)  %>% # groups rows with label
      pack_rows(., "pH inshore", 13, 15)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
d TA inshore
Sub_region 450697.69 150232.56 3 8.42 32.03 0.00
Season 1250626.86 416875.62 3 371.65 88.88 0.00
Sub_region:Season 166830.83 18536.76 9 371.64 3.95 0.00
d DIC inshore
Sub_region 121639.36 40546.45 3 7.81 7.96 0.01
Season 2120498.90 706832.97 3 369.01 138.78 0.00
Sub_region:Season 181134.87 20126.10 9 369.01 3.95 0.00
d pCO2 inshore
Sub_region 48532.82 16177.61 3 7.24 3.15 0.09
Season 1336460.93 445486.98 3 368.48 86.75 0.00
Sub_region:Season 108532.96 12059.22 9 368.48 2.35 0.01
Omega inshore
Sub_region 6.03 2.01 3 7.07 14.60 0.00
Season 40.79 13.60 3 374.36 98.84 0.00
Sub_region:Season 3.52 0.39 9 374.36 2.85 0.00
pH inshore
Sub_region 0.07 0.02 3 7.44 6.18 0.02
Season 1.32 0.44 3 374.69 109.72 0.00
Sub_region:Season 0.07 0.01 9 374.70 1.86 0.06
#export_summs(dTA_season, dDIC_season, dpCO2_season,  scale = TRUE)
    Seasonal_models_in<-list("d TA" = dTA_season_in, 
                       "d DIC" = dDIC_season_in, 
                       "d pCO2" = dpCO2_season_in, 
                       "Omega" = Omega_season_in,
                       "pH" = pH_season_in)
    
    modelsummary(Seasonal_models_in, stars = TRUE, 
                 #statistic = c('std.error', 'p.value', 'conf.int'),
                 title = 'Seasonal and spatial models for inshore reefs'#,
                 #coef_map=factor_order
                 )
Seasonal and spatial models for inshore reefs
d TA d DIC d pCO2 Omega pH
(Intercept) 40.632* 46.843* −3.618 3.617*** 8.080***
(16.867) (19.066) (19.926) (0.099) (0.017)
Sub_regionUK 8.140 −3.738 −19.226 0.094 0.017
(22.663) (25.473) (26.556) (0.132) (0.022)
Sub_regionMK 16.388 8.657 −5.210 0.099 0.009
(22.437) (25.251) (26.340) (0.131) (0.022)
Sub_regionLK −33.045 −19.049 22.510 −0.179 −0.021
(21.397) (24.255) (25.380) (0.126) (0.021)
SeasonSpring −103.117*** −137.861*** −58.117* 0.455*** 0.012
(22.865) (23.833) (23.932) (0.121) (0.021)
SeasonSummer −86.879*** −57.259* 81.270** −0.018 −0.122***
(23.855) (24.860) (24.964) (0.129) (0.022)
SeasonFall −14.359 26.433 82.201*** −0.298* −0.088***
(22.344) (23.284) (23.380) (0.121) (0.021)
Sub_regionUKSeasonSpring −2.726 −30.364 −24.107 0.303+ 0.034
(30.686) (31.985) (32.120) (0.162) (0.028)
Sub_regionMKSeasonSpring −34.810 −48.046 −16.696 0.100 0.011
(29.563) (30.811) (30.939) (0.158) (0.027)
Sub_regionLKSeasonSpring −28.905 −21.590 2.108 −0.095 −0.013
(28.713) (29.930) (30.056) (0.153) (0.026)
Sub_regionUKSeasonSummer 2.874 −11.247 −22.133 0.194 0.012
(31.431) (32.758) (32.895) (0.170) (0.029)
Sub_regionMKSeasonSummer −118.938*** −120.630*** −43.065 −0.096 0.004
(31.403) (32.727) (32.863) (0.170) (0.029)
Sub_regionLKSeasonSummer −104.496*** −82.765* 0.301 −0.197 −0.016
(30.818) (32.477) (32.613) (0.169) (0.029)
Sub_regionUKSeasonFall 10.007 26.763 41.889 −0.128 −0.027
(30.300) (31.579) (31.710) (0.164) (0.028)
Sub_regionMKSeasonFall −25.859 −31.677 −28.721 0.040 0.015
(29.476) (30.722) (30.851) (0.160) (0.027)
Sub_regionLKSeasonFall −56.447* −61.698* −35.879 0.027 0.015
(28.442) (29.644) (29.768) (0.154) (0.026)
SD (Intercept SiteID) 4.142 11.295 13.772 0.058 0.010
SD (Observations) 68.485 71.367 71.662 0.371 0.063
Num.Obs. 393 391 391 397 397
R2 Marg. 0.517 0.562 0.423 0.503 0.481
R2 Cond. 0.519 0.573 0.444 0.515 0.492
AIC 4344.4 4356.2 4360.7 416.9 −931.7
BIC 4415.9 4427.7 4432.2 488.6 −860.0
ICC 0.0 0.0 0.0 0.0 0.0
RMSE 67.00 69.58 69.81 0.36 0.06
+ p
    #modelsummary(Omega_models, estimate = "p.value")

Figure 4: Models

Figure_4<-ggarrange(DeltaYearTA+ theme(axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 legend.position = "none"),
                  DeltaYearDIC+ theme(legend.position = "none",
                                 axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 strip.text.x = element_blank()),
                  DeltaYearpH + theme(legend.position = "none",
                                 axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 strip.text.x = element_blank()),
                  DeltaYearAra+ theme(legend.position = "bottom",
                                 strip.text.x = element_blank(),
                                 panel.spacing = unit(0.8, "lines")),
          labels = c("A", "B", "C", "D"),
          ncol = 1, nrow = 4, heights = c(1, 0.9, 0.9, 1.2))
Figure_4

#ggsave(file="FLK_results/Figures/Fig_4/Figure_4.svg", plot=Figure_4, dpi = 300, width=8, height=7)

6 LMER long trend MODELS

  • The F statistic in a regression model is used to test whether there is a linear model of the data - overall, or equivalently that your model is no better than a model with just the intercept.

  • The t statistic for a coefficient in a linear model tests the H0 that the true coefficient is 0.

  • The t-statistic is telling you about each coefficient individually. You can have a model with a low overall linear fit, but one individual coefficient may be relatively contributing a lot to explanation the variation in the DV that is explained on the assumption that there is a linear model.

Data and plots prep

Trends.data<-FLK.data[FLK.data$Year>2014, ]
#summary(Trends.data)

Reef.Trends.data<-WS.reef[WS.reef$Year>2014, ]
#Reef.Trends.data<-Reef.Trends.data[Reef.Trends.data$Extreme=="Normal", ]
#summary(Reef.Trends.data$Extreme)

Trends.ocean<-Trends.data[Trends.data$Zone=="Oceanic", ]

Trends.offshore<-Reef.Trends.data[Reef.Trends.data$Zone=="Offshore", ]
Trends.midchanel<-Reef.Trends.data[Reef.Trends.data$Zone=="Mid channel", ]
Trends.inshore<-Reef.Trends.data[Reef.Trends.data$Zone=="Inshore", ]

Long_plot<- ggplot(Trends.data) +
        MyTheme +  
        #scale_shape_manual(values=c(24, 25, 21))+
        #guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(axis.title.x = element_blank())+
        scale_x_date(date_breaks = "2 years",
                     date_labels = "%Y",
                     expand = c(0.02, 0.02))

Long_plot2<- ggplot() +
        MyTheme +  
        #scale_shape_manual(values=c(24, 25, 21))+
        #guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(axis.title.x = element_blank(),
                axis.text.x = element_text(angle = 0, vjust = 0.5))+
        scale_x_date(date_breaks = "2 years",
                     date_labels = "%Y",
                     expand = c(0.02, 0.02))
xs <- as.Date(as.character("2018-11-20"))

factor_order <- c('Year'    = 'Year',
                  '(Intercept)' = 'Intercept',
                  'Sub_regionUK'    = 'Upper Keys',
                  'Sub_regionMK'    = 'Middle Keys',
                  'Sub_regionLK'    = 'Lower Keys')

Temperature-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$Aragonite_Sat_W
## W = 0.97568, p-value = 4.918e-14

## Model with all data
Temo_all_o<-lmer(Temperature_C~Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
  step(Temo_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    33 -2180.5 4427.0                         
## (1 | SiteID)          1   32 -2180.5 4425.0    0.0  1          1    
## (1 | Month)           0   31 -3246.8 6555.6 2132.6  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated  Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Zone:Sub_region          1  4.1820  0.5228     8 1277.1  0.3594 0.94172  
## Zone:Sub_region               2  6.2299  0.7787     8 1285.0  0.5376 0.82876  
## Year:Sub_region               3  6.4323  2.1441     3 1293.0  1.4844 0.21705  
## Sub_region                    4 10.4571  3.4857     3 1296.0  2.4104 0.06538 .
## Year:Zone                     0 13.3233  4.4411     3 1298.9  3.0611 0.02730 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Temperature_C ~ Year + Zone + (1 | Month) + Year:Zone
Temp_all_1<-lmer(Temperature_C ~ Year + Zone + Sub_region + (1 | Month), data=Trends.data)

anova(Temp_all_1, Temo_all_o)
    summary(Temp_all_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Temperature_C ~ Year + Zone + Sub_region + (1 | Month)
##    Data: Trends.data
## 
## REML criterion at convergence: 4323.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -7.2533 -0.5516  0.0026  0.5207  3.4702 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 7.995    2.827   
##  Residual             1.453    1.205   
## Number of obs: 1318, groups:  Month, 12
## 
## Fixed effects:
##                   Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)      3.707e+01  3.915e+01  1.302e+03   0.947  0.34390    
## Year            -5.101e-03  1.939e-02  1.301e+03  -0.263  0.79256    
## ZoneMid channel  2.843e-01  8.978e-02  1.299e+03   3.166  0.00158 ** 
## ZoneOffshore     3.630e-01  8.531e-02  1.299e+03   4.255 2.24e-05 ***
## ZoneOceanic      4.773e-01  1.150e-01  1.299e+03   4.150 3.54e-05 ***
## Sub_regionUK     2.293e-01  1.092e-01  1.299e+03   2.100  0.03596 *  
## Sub_regionMK     1.714e-01  1.043e-01  1.299e+03   1.643  0.10054    
## Sub_regionLK     3.113e-02  1.022e-01  1.299e+03   0.305  0.76064    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   ZnMdch ZnOffs ZnOcnc Sb_rUK Sb_rMK
## Year        -1.000                                          
## ZoneMdchnnl  0.007 -0.009                                   
## ZoneOffshor  0.015 -0.016  0.507                            
## ZoneOceanic  0.008 -0.009  0.380  0.401                     
## Sub_reginUK -0.021  0.019  0.041 -0.016 -0.079              
## Sub_reginMK -0.008  0.007 -0.008 -0.012 -0.157  0.607       
## Sub_reginLK -0.014  0.012 -0.005 -0.045 -0.154  0.620  0.661
    anova(Temp_all_1)
    ranova(Temp_all_1)
# Obtain slopes
    #ranef(Temp_all_1)
    #fixef(Temp_all_1)
    #coef(Temp_all_1)$Month
    #coef(Temp_all_1)$Zone
  m.lst <- lstrends(Temp_all_1, "Zone", var="Year")
  m.lst
##  Zone        Year.trend     SE   df lower.CL upper.CL
##  Inshore        -0.0051 0.0194 1301  -0.0432    0.033
##  Mid channel    -0.0051 0.0194 1301  -0.0432    0.033
##  Offshore       -0.0051 0.0194 1301  -0.0432    0.033
##  Oceanic        -0.0051 0.0194 1301  -0.0432    0.033
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
  #pairs(m.lst)

Inshore

# Inshore Omega
  hist(Trends.inshore$Temperature_C)

  shapiro.test(Trends.inshore$Aragonite_Sat_W) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$Aragonite_Sat_W
## W = 0.98599, p-value = 0.001134
  Temp_in_0<-lmer(Temperature_C~Year * Sub_region + (1|Month)+
                                    #(1|Zone)+             
                                    (1|SiteID), data=Trends.inshore)
  
  anova(Temp_in_0)
  ranova(Temp_in_0)
  step(Temp_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -711.34 1444.7                         
## (1 | SiteID)          1   10 -711.34 1442.7   0.00  1          1    
## (1 | Month)           0    9 -996.55 2011.1 570.42  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1 6.2800  2.0933     3 356.00  0.9652 0.40922  
## Sub_region               2 7.1804  2.3935     3 359.00  1.1039 0.34748  
## Year                     3 6.9370  6.9370     1 364.47  3.1967 0.07462 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Temperature_C ~ (1 | Month)
  Temp_in<-lmer(Temperature_C ~ (1 | Month),
                 data=Trends.inshore)
  ranova(Temp_in)
  summary(Temp_in)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Temperature_C ~ (1 | Month)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 1414.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.9573 -0.5257  0.0358  0.6570  2.6540 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 11.547   3.398   
##  Residual              2.182   1.477   
## Number of obs: 375, groups:  Month, 12
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  26.8688     0.9843 10.9722    27.3 1.95e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  plot(Temp_in)

    par(mfrow=c(1,2))
    qqnorm(resid(Temp_in))
    acf(resid(Temp_in), main="acf(resid(Temperature Inshore))")

    par(mfrow=c(1,1))

Mid channel

hist(Trends.midchanel$Temperature_C)

shapiro.test(Trends.midchanel$Temperature_C)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$Temperature_C
## W = 0.9747, p-value = 8.254e-06
Temp_mc_0<-lmer(Temperature_C~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)

anova(Temp_mc_0)
ranova(Temp_mc_0)
step(Temp_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -563.69 1149.4                         
## (1 | SiteID)          1   10 -563.69 1147.4   0.00  1          1    
## (1 | Month)           0    9 -865.39 1748.8 603.41  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
## Year:Sub_region          1 0.8462 0.28208     3 330.98  0.2380 0.8698
## Year                     2 0.0189 0.01891     1 335.72  0.0161 0.8992
## Sub_region               3 3.7153 1.23845     3 334.99  1.0552 0.3683
## 
## Model found:
## Temperature_C ~ (1 | Month)
Temp_mc<-lmer(Temperature_C ~ (1 | Month),
               data = Trends.midchanel)
  summary(Temp_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Temperature_C ~ (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 1110.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.8831 -0.5762 -0.0149  0.5622  2.6584 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 8.191    2.862   
##  Residual             1.174    1.084   
## Number of obs: 350, groups:  Month, 12
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  27.1732     0.8285 10.9748    32.8 2.64e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  plot(Temp_mc)

    par(mfrow=c(1,2))
    qqnorm(resid(Temp_mc))
    acf(resid(Temp_mc), main="acf(resid(Temperature Mid-channel))")

    par(mfrow=c(1,1))

Offshore

hist(Trends.offshore$Temperature_C)

shapiro.test(Trends.offshore$Temperature_C)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$Temperature_C
## W = 0.96787, p-value = 4.179e-08
Temp_of_0<-lmer(Temperature_C~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
#summary(Omega_of_0)    
anova(Temp_of_0)
ranova(Temp_of_0)
step(Temp_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -537.53 1097.0                         
## (1 | SiteID)          1   10 -537.53 1095.1   0.01  1     0.9069    
## (1 | Month)           0    9 -987.94 1993.9 900.81  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1 2.0223  0.6741     3 410.98  1.1643 0.32304  
## Year                     2 1.3351  1.3351     1 415.07  2.3033 0.12986  
## Sub_region               3 3.7159  1.2386     3 414.99  2.1293 0.09591 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Temperature_C ~ (1 | Month)
Temp_of<-lmer(Temperature_C ~ Year + (1 | Month), 
               data =Trends.offshore)
  summary(Temp_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Temperature_C ~ Year + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 1063.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.3354 -0.6359 -0.0476  0.5112  3.2539 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 6.6599   2.5807  
##  Residual             0.5843   0.7644  
## Number of obs: 430, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error        df t value Pr(>|t|)
## (Intercept) -39.33001   43.54925 418.32606  -0.903    0.367
## Year          0.03298    0.02158 418.09323   1.529    0.127
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  plot(Temp_of)

    par(mfrow=c(1,2))
    qqnorm(resid(Temp_of))
    acf(resid(Temp_of), main="acf(resid(Temperature offshore))")

    par(mfrow=c(1,1))

Oceanic

hist(Trends.ocean$Temperature_C)

shapiro.test(Trends.ocean$Temperature_C)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$Temperature_C
## W = 0.94909, p-value = 1.261e-05
Temp_oc_0<-lmer(Temperature_C ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)

  anova(Temp_oc_0)
  ranova(Temp_oc_0)
  step(Temp_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik   AIC    LRT Df Pr(>Chisq)    
## <none>                     9 -213.15 444.3                         
## (1 | SiteID)          1    8 -213.15 442.3   0.00  1          1    
## (1 | Month)           0    7 -361.25 736.5 296.21  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
## Year:Sub_region          1 0.27442 0.13721     2 145.95  0.2614 0.7704
## Sub_region               2 0.19394 0.09697     2 147.94  0.1866 0.8300
## Year                     3 0.43900 0.43900     1 150.93  0.8539 0.3569
## 
## Model found:
## Temperature_C ~ (1 | Month)
Temp_oc<-lmer(Temperature_C ~(1 | Month), data = Trends.ocean)
  summary(Temp_oc)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Temperature_C ~ (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: 411.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.2602 -0.5986 -0.1481  0.4997  3.0316 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 5.6611   2.3793  
##  Residual             0.5142   0.7171  
## Number of obs: 163, groups:  Month, 12
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  27.3920     0.6895 10.9185   39.73 3.68e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  ranova(Temp_oc)
  plot(Temp_oc)

    par(mfrow=c(1,2))
    qqnorm(resid(Temp_oc))
    acf(resid(Temp_oc), main="acf(resid(Temperature oceanic))")

    par(mfrow=c(1,1))

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.Temp_in_0 <- data.frame (anova(Temp_in_0))
    av.Temp_mc_0 <- data.frame (anova(Temp_mc_0) )
    av.Temp_of_0 <- data.frame (anova(Temp_of_0))
    av.Temp_oc_0 <- data.frame (anova(Temp_oc_0))
    
    # Putting all into one dataframe/table
    anova_Temp_0 <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                                      rbind(av.Temp_in_0, av.Temp_mc_0,
                                            av.Temp_of_0, av.Temp_oc_0))) 
    colnames(anova_Temp_0) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_Temp_0) <- NULL
    
    # create HTML table using kableExtra
    anova_Temp_0 %>% kable("html", digits=2, 
        caption="Initial temperature models fixed factors: Year*Region") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Temperature inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "Temperature mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "Temperature offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Temperature ocean", 10, 12)  
Initial temperature models fixed factors: Year*Region
Sum Sq Mean Sq N Df D Df F value Pr(>F)
Temperature inshore
Year 5.24 5.24 1 358.41 2.42 0.12
Sub_region 6.28 2.09 3 356.02 0.96 0.41
Year:Sub_region 6.28 2.09 3 356.02 0.97 0.41
Temperature mid-channel
Year 0.02 0.02 1 332.66 0.02 0.90
Sub_region 0.85 0.28 3 330.96 0.24 0.87
Year:Sub_region 0.85 0.28 3 330.96 0.24 0.87
Temperature offshore
Year 2.03 2.03 1 404.69 3.51 0.06
Sub_region 2.02 0.67 3 403.79 1.16 0.32
Year:Sub_region 2.02 0.67 3 403.79 1.17 0.32
Temperature ocean
Year 0.24 0.24 1 146.88 0.47 0.50
Sub_region 0.27 0.14 2 145.95 0.26 0.77
Year:Sub_region 0.27 0.14 2 145.95 0.26 0.77
# R-ANOVAs    
    rav.Temp_in_0 <- data.frame (ranova(Temp_in_0))
    rav.Temp_mc_0 <- data.frame (ranova(Temp_mc_0) )
    rav.Temp_of_0 <- data.frame (ranova(Temp_of_0))
    rav.Temp_oc_0 <- data.frame (ranova(Temp_oc_0))
    
    # Putting all into one dataframe/table
    ranova_Temp_0 <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.Temp_in_0, rav.Temp_mc_0,
                            rav.Temp_of_0, rav.Temp_oc_0))) 
    colnames(ranova_Temp_0) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_Temp_0) <- NULL
    
    # create HTML table using kableExtra
    ranova_Temp_0 %>% kable("html", digits=2,
         caption="Initial temperature models random factors: Month+Station") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Temperature inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "Temperature mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "Temperature offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Temperature ocean", 10, 12)  
Initial temperature models random factors: Month+Station
npar logLik AIC LRT DF Pr(>Chi Sq)
Temperature inshore
<none> 11 -711.34 1444.67
(1 | Month) 10 -996.55 2013.09 570.42 1 0.00
(1 | SiteID) 10 -711.34 1442.67 0.00 1 1.00
Temperature mid-channel
<none> 11 -563.69 1149.37
(1 | Month) 10 -865.39 1750.78 603.41 1 0.00
(1 | SiteID) 10 -563.69 1147.37 0.00 1 1.00
Temperature offshore
<none> 11 -537.53 1097.05
(1 | Month) 10 -987.94 1995.87 900.82 1 0.00
(1 | SiteID) 10 -537.53 1095.07 0.01 1 0.91
Temperature ocean
<none> 9 -213.15 444.30
(1 | Month) 8 -361.25 738.50 296.21 1 0.00
(1 | SiteID) 8 -213.15 442.30 0.00 1 1.00
Temp_models_0<-list("Inshore" = Temp_in_0, 
                   "Mid channel" = Temp_mc_0, 
                   "Offshore" = Temp_of_0, 
                   "Ocean" = Temp_oc_0)
modelsummary(Temp_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Initial temperature model outputs (all factors)',
             coef_map=factor_order)
Initial temperature model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year 0.002 0.026 0.098* −0.008
(0.088) (0.066) (0.046) (0.067)
Intercept 22.013 −25.149 −170.660+ 43.788
(177.560) (132.980) (92.279) (134.751)
Upper Keys 58.619 108.420 124.789
(229.290) (185.850) (116.234)
Middle Keys 188.497 23.575 131.161 −76.557
(222.390) (164.934) (115.203) (157.091)
Lower Keys 338.064 112.358 203.818+ −114.026
(222.876) (165.742) (109.332) (157.611)
Num.Obs. 375 350 430 163
R2 Marg. 0.028 0.011 0.002 0.013
R2 Cond. 0.920
AIC 1444.7 1149.4 1097.1 444.3
BIC 1487.9 1191.8 1141.8 472.1
ICC 0.9
RMSE 1.44 1.06 0.74 0.69
+ p
#modelsummary(Omega_models, estimate = "p.value")

Models with non-significant factors removed

Temp_models<-list("Inshore" = Temp_in, 
                   "Mid channel" = Temp_mc, 
                   "Offshore" = Temp_of, 
                   "Ocean" = Temp_oc)
modelsummary(Temp_models, stars = TRUE, 
            #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Final temperature model outputs (dropped factors)',
             coef_map=factor_order)
Final temperature model outputs (dropped factors)
Inshore Mid channel Offshore Ocean
Year 0.033
(0.022)
Intercept 26.869*** 27.173*** −39.330 27.392***
(0.984) (0.828) (43.549) (0.690)
Num.Obs. 375 350 430 163
R2 Marg. 0.000 0.000 0.001 0.000
R2 Cond. 0.841 0.875 0.919 0.917
AIC 1420.8 1116.3 1071.4 417.5
BIC 1432.5 1127.9 1087.7 426.8
ICC 0.8 0.9 0.9 0.9
RMSE 1.45 1.06 0.75 0.69
+ p
#modelsummary(Temp_models, estimate = "p.value")

In summary, temperature slope is only significant for offshore zone.

TA-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$TA_umol_kg
## W = 0.81138, p-value < 2.2e-16

## Model with all data
TA_all_o<-lmer(TA_umol_kg~Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
  step(TA_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik   AIC     LRT Df Pr(>Chisq)    
## <none>                    33 -6943.8 13954                          
## (1 | SiteID)          1   32 -6944.9 13954   2.239  1     0.1346    
## (1 | Month)           0   31 -7063.9 14190 237.930  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)    
## Year:Zone:Sub_region          1  13048    1631     8 1273.9  0.6529 0.73328    
## Year:Zone                     2  15546    5182     3 1282.0  2.0789 0.10120    
## Year:Sub_region               3  18048    6016     3 1285.1  2.4075 0.06564 .  
## Year                          0  14495   14495     1 1285.4  5.7815 0.01634 *  
## Zone:Sub_region               0 286602   35825     8 1288.0 14.2889 < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## TA_umol_kg ~ Year + Zone + Sub_region + (1 | Month) + Zone:Sub_region
TA_all_1<-lmer(TA_umol_kg ~ Year + Zone + Sub_region + 
                  (1 | Month) + (1 | SiteID) + 
                  Year:Sub_region + Zone:Sub_region, data=Trends.data)

    summary(TA_all_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: TA_umol_kg ~ Year + Zone + Sub_region + (1 | Month) + (1 | SiteID) +  
##     Year:Sub_region + Zone:Sub_region
##    Data: Trends.data
## 
## REML criterion at convergence: 13946.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.0797 -0.4207  0.0151  0.5279  5.5958 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  SiteID   (Intercept)   36.46   6.039  
##  Month    (Intercept)  659.09  25.673  
##  Residual             2476.05  49.760  
## Number of obs: 1315, groups:  SiteID, 38; Month, 12
## 
## Fixed effects:
##                                Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                   2.285e+02  3.463e+03  1.272e+03   0.066 0.947399
## Year                          1.064e+00  1.716e+00  1.272e+03   0.620 0.535320
## ZoneMid channel               4.266e+00  1.026e+01  2.250e+01   0.416 0.681511
## ZoneOffshore                  6.593e+00  1.024e+01  2.229e+01   0.644 0.526093
## ZoneOceanic                   9.523e+01  9.487e+00  2.366e+01  10.038 5.31e-10
## Sub_regionUK                  1.967e+03  4.437e+03  1.265e+03   0.443 0.657612
## Sub_regionMK                 -7.290e+03  4.188e+03  1.264e+03  -1.741 0.081942
## Sub_regionLK                  5.396e+01  4.138e+03  1.264e+03   0.013 0.989598
## Year:Sub_regionUK            -9.743e-01  2.199e+00  1.265e+03  -0.443 0.657771
## Year:Sub_regionMK             3.596e+00  2.075e+00  1.264e+03   1.733 0.083362
## Year:Sub_regionLK            -7.026e-02  2.051e+00  1.264e+03  -0.034 0.972672
## ZoneMid channel:Sub_regionUK  1.000e+00  1.422e+01  2.455e+01   0.070 0.944461
## ZoneOffshore:Sub_regionUK    -2.036e+00  1.343e+01  2.369e+01  -0.152 0.880766
## ZoneOceanic:Sub_regionUK     -8.820e+01  1.584e+01  2.721e+01  -5.567 6.50e-06
## ZoneMid channel:Sub_regionMK  1.824e+01  1.331e+01  2.296e+01   1.370 0.183870
## ZoneOffshore:Sub_regionMK     2.796e+01  1.329e+01  2.278e+01   2.104 0.046615
## ZoneOceanic:Sub_regionMK     -5.080e+01  1.350e+01  2.425e+01  -3.764 0.000943
## ZoneMid channel:Sub_regionLK  5.640e+01  1.324e+01  2.244e+01   4.260 0.000308
## ZoneOffshore:Sub_regionLK     8.324e+01  1.289e+01  2.236e+01   6.457 1.57e-06
##                                 
## (Intercept)                     
## Year                            
## ZoneMid channel                 
## ZoneOffshore                    
## ZoneOceanic                  ***
## Sub_regionUK                    
## Sub_regionMK                 .  
## Sub_regionLK                    
## Year:Sub_regionUK               
## Year:Sub_regionMK            .  
## Year:Sub_regionLK               
## ZoneMid channel:Sub_regionUK    
## ZoneOffshore:Sub_regionUK       
## ZoneOceanic:Sub_regionUK     ***
## ZoneMid channel:Sub_regionMK    
## ZoneOffshore:Sub_regionMK    *  
## ZoneOceanic:Sub_regionMK     ***
## ZoneMid channel:Sub_regionLK ***
## ZoneOffshore:Sub_regionLK    ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## fit warnings:
## fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
    anova(TA_all_1)
    ranova(TA_all_1)
    plot(TA_all_1)

    par(mfrow=c(1,2))
    qqnorm(resid(TA_all_1))
    acf(resid(TA_all_1), main="acf(resid(TA all))")

    par(mfrow=c(1,1))
    
  m.lst <- lstrends(TA_all_1, "Sub_region", var="Year")
  m.lst
##  Sub_region Year.trend   SE   df lower.CL upper.CL
##  BB             1.0640 1.72 1270    -2.30     4.43
##  UK             0.0897 1.50 1276    -2.85     3.03
##  MK             4.6600 1.31 1273     2.09     7.23
##  LK             0.9937 1.27 1274    -1.51     3.49
## 
## Results are averaged over the levels of: Zone 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
  pairs(m.lst)
##  contrast estimate   SE   df t.ratio p.value
##  BB - UK    0.9743 2.20 1264   0.443  0.9709
##  BB - MK   -3.5961 2.08 1262  -1.733  0.3070
##  BB - LK    0.0703 2.05 1263   0.034  1.0000
##  UK - MK   -4.5704 1.90 1265  -2.402  0.0771
##  UK - LK   -0.9040 1.87 1265  -0.483  0.9629
##  MK - LK    3.6663 1.73 1263   2.120  0.1473
## 
## Results are averaged over the levels of: Zone 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 4 estimates

Inshore

# Inshore TA
  hist(Trends.inshore$TA_umol_kg)

  shapiro.test(Trends.inshore$TA_umol_kg) # Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$TA_umol_kg
## W = 0.97131, p-value = 9.403e-07
  TA_in_0<-lmer(TA_umol_kg~Year * Sub_region + (1|Month)+
                                    #(1|Zone)+             
                                    (1|SiteID), data=Trends.inshore)
  #summary(TA_in_0)
  step(TA_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -2111.8 4245.5                          
## (1 | SiteID)          1   10 -2112.4 4244.9   1.315  1     0.2515    
## (1 | Month)           0    9 -2188.0 4394.0 151.123  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)    
## Year:Sub_region          1  23921    7974     3 356.06  1.6785 0.17127    
## Year                     2  15420   15420     1 369.35  3.2277 0.07322 .  
## Sub_region               0 500931  166977     3 359.97 34.7828 < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## TA_umol_kg ~ Sub_region + (1 | Month)
  TA_in<-lmer(TA_umol_kg ~ Sub_region +
               (1 | Month) + (1 | SiteID),
                            data=Trends.inshore)
    anova(TA_in)
    ranova(TA_in)
    summary(TA_in)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: TA_umol_kg ~ Sub_region + (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 4249.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.4843 -0.5830  0.0341  0.5873  3.2900 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 3775.8   61.45   
##  SiteID   (Intercept)  102.3   10.12   
##  Residual             4732.0   68.79   
## Number of obs: 375, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##              Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  2377.997     20.799   15.581 114.333  < 2e-16 ***
## Sub_regionUK    1.572     14.196    7.250   0.111 0.914851    
## Sub_regionMK  -31.679     14.030    6.934  -2.258 0.058864 .  
## Sub_regionLK  -87.696     13.967    6.807  -6.279 0.000462 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.394              
## Sub_reginMK -0.399  0.583       
## Sub_reginLK -0.401  0.585  0.594
  plot(TA_in)

    par(mfrow=c(1,2))
    qqnorm(resid(TA_in))
    acf(resid(TA_in), main="acf(resid(TA Inshore))")

    par(mfrow=c(1,1))
  
  TA_in.emmc<-emmeans(TA_in, ~Sub_region)
    TA_in.emmc<-multcomp::cld(TA_in.emmc)
    #TA_in.emmc<-as.data.frame(TA_in.emmc[complete.cases(TA_in.emmc),])
    TA_in.emmc<-TA_in.emmc[order(TA_in.emmc$Sub_region),]
    TA_in.emmc
  #write.csv(TA_in.emmc, "FLK_results/TA_in.emmc_POST.csv")
# Create a new data frame for independent variables  
  In_Newdata<-expand.grid(Sub_region=unique(Trends.inshore$Sub_region),
                          Year=seq((min(Trends.inshore$Year)-0),
                                   (max(Trends.inshore$Year)+1)))

  In_TA_Pred <- predict(TA_in, newdata=In_Newdata, 
                         re.form=NA, level=0, asList = FALSE)
  
  In_TA_Pred <-cbind(In_Newdata, In_TA_Pred)
  In_TA_Pred$Date<-as.Date(as.character(In_TA_Pred$Year), format = "%Y")
  
  
# Plot raw data point and fitted model 
  In_TA_Modeled<-Long_plot2+ 
     scale_y_continuous(limits = c(2000,2650),
                       name=(expression(paste("TA (", mu, "mol ",
                                              kg^-1, ")"))),
                       #breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.inshore, 
                               aes(y=TA_umol_kg, x=Date, 
                                  fill = Sub_region), 
                                  #colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=21)+
      geom_line(data=In_TA_Pred, aes(y = In_TA_Pred,
                                      x=Date, colour = Sub_region), linetype=2, size=1) 
  In_TA_Modeled

Mid channel

hist(Trends.midchanel$TA_umol_kg)

shapiro.test(Trends.midchanel$TA_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$TA_umol_kg
## W = 0.8639, p-value < 2.2e-16
TA_mc_0<-lmer(TA_umol_kg~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)
  anova(TA_mc_0)
  ranova(TA_mc_0)
  step(TA_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1817.1 3656.2                         
## (1 | Month)           0   10 -1849.4 3718.9 64.655  1  8.922e-16 ***
## (1 | SiteID)          0   10 -1818.7 3657.4  3.158  1    0.07558 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  6340.2  2113.4     3 325.57  1.0805 0.35744  
## Year                     2  3283.1  3283.1     1 337.79  1.6769 0.19622  
## Sub_region               3 26280.6  8760.2     3   6.22  4.4754 0.05406 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## TA_umol_kg ~ (1 | Month) + (1 | SiteID)
TA_mc<-lmer(TA_umol_kg ~ Sub_region + (1 | Month),
               data = Trends.midchanel)
  summary(TA_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: TA_umol_kg ~ Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3656.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.8190 -0.3897  0.0837  0.5435  3.6029 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  693.3   26.33   
##  Residual             2007.2   44.80   
## Number of obs: 350, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  2378.905      9.320   19.839 255.238  < 2e-16 ***
## Sub_regionUK    2.686      7.773  335.209   0.346   0.7299    
## Sub_regionMK  -15.174      6.879  335.070  -2.206   0.0281 *  
## Sub_regionLK  -30.826      6.846  335.368  -4.503 9.26e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.392              
## Sub_reginMK -0.444  0.530       
## Sub_reginLK -0.447  0.533  0.604
  anova(TA_mc)
  plot(TA_mc)

    par(mfrow=c(1,2))
    qqnorm(resid(TA_mc))
    acf(resid(TA_mc), main="acf(resid(TA mid Channel))")  

    par(mfrow=c(1,1))
    
  TA_md.emmc<-emmeans(TA_mc, ~Sub_region)
    TA_md.emmc<-multcomp::cld(TA_md.emmc)
    #TA_md.emmc<-as.data.frame(TA_md.emmc[complete.cases(TA_md.emmc),])
    TA_md.emmc<-TA_md.emmc[order(TA_md.emmc$Sub_region),]
    TA_md.emmc
  #write.csv(TA_md.emmc, "FLK_results/Model_TA_mc_POST.csv")
# Create a new data frame for independent variables  
  Mc_Newdata<-expand.grid(Sub_region=unique(Trends.midchanel$Sub_region),
                          Year=seq((min(Trends.midchanel$Year)-0),
                                   (max(Trends.midchanel$Year)+1)))

  Mc_TA_Pred <- predict(TA_mc, newdata=Mc_Newdata, 
                         re.form=NA, level=0, asList = FALSE)
  
  Mc_TA_Pred <-cbind(Mc_Newdata, Mc_TA_Pred)
  Mc_TA_Pred$Date<-as.Date(as.character(Mc_TA_Pred$Year), format = "%Y")
  
# Plot raw data point and fitted model 
  Mc_TA_Modeled<-Long_plot2+ 
     scale_y_continuous(limits = c(2000,2650),
                       name=(expression(paste("TA (", mu, "mol ",
                                              kg^-1, ")"))),
                       #breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
      geom_point(data=Trends.midchanel, 
                               aes(y=TA_umol_kg, x=Date, 
                                  fill = Sub_region), 
                                  #colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=23)+
      geom_line(data=Mc_TA_Pred, aes(y = Mc_TA_Pred,
                                      x=Date, colour = Sub_region), linetype=2, size=1) 
  Mc_TA_Modeled

Offshore

hist(Trends.offshore$TA_umol_kg)

shapiro.test(Trends.offshore$TA_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$TA_umol_kg
## W = 0.88506, p-value < 2.2e-16
TA_of_0<-lmer(TA_umol_kg~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(TA_of_0)    
  anova(TA_of_0)
  ranova(TA_of_0)
  step(TA_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1856.1 3734.2                         
## (1 | SiteID)          1   10 -1856.1 3732.2  0.000  1          1    
## (1 | Month)           0    9 -1878.5 3775.1 44.909  1  2.064e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  154.6   51.53     3 408.87  0.1454 0.93261  
## Year                     0 1806.8 1806.84     1 400.97  5.1298 0.02405 *
## Sub_region               0 2996.0  998.68     3 412.25  2.8353 0.03792 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## TA_umol_kg ~ Year + Sub_region + (1 | Month)
TA_of<-lmer(TA_umol_kg ~ Year + Sub_region + (1 | Month), 
               data =Trends.offshore)
  summary(TA_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: TA_umol_kg ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3719
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.5140 -0.3773  0.1021  0.5952  3.4228 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  58.97    7.679  
##  Residual             352.23   18.768  
## Number of obs: 427, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)  
## (Intercept)    41.5577  1032.8949  400.9112   0.040   0.9679  
## Year            1.1592     0.5118  400.9684   2.265   0.0241 *
## Sub_regionUK   -0.5389     2.8906  411.7814  -0.186   0.8522  
## Sub_regionMK   -6.2459     2.8620  411.7525  -2.182   0.0296 *
## Sub_regionLK   -5.2199     2.7133  412.6123  -1.924   0.0551 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.004  0.002              
## Sub_reginMK -0.005  0.003  0.591       
## Sub_reginLK -0.007  0.006  0.625  0.632
  anova(TA_of) 
plot(TA_of)

  par(mfrow=c(1,2))
  qqnorm(resid(TA_of))
  acf(resid(TA_of), main="acf(resid(TA offshore))")  

  par(mfrow=c(1,1))
    
  TA_of.emmc<-emmeans(TA_of, ~Sub_region)
    TA_of.emmc<-multcomp::cld(TA_of.emmc)
    #TA_of.emmc<-as.data.frame(TA_of.emmc[complete.cases(TA_of.emmc),])
    TA_of.emmc<-TA_of.emmc[order(TA_of.emmc$Sub_region),]
    TA_of.emmc
#write.csv(TA_of.emmc, "FLK_results/Model_TA_of.emmc_POST.csv")
# Create a new data frame for independent variables  
  Of_Newdata<-expand.grid(one=unique(Trends.offshore$Zone),
                                Sub_region=unique(Trends.offshore$Sub_region),
                          Year=seq((min(Trends.offshore$Year)-0), (max(Trends.offshore$Year)+1)))
  Of_TA_Pred <- predict(TA_of, newdata=Of_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Of_TA_Pred <-cbind(Of_Newdata, Of_TA_Pred)
  Of_TA_Pred$Date<-as.Date(as.character(Of_TA_Pred$Year), format = "%Y")
  
  # Model summary for labels
  slope<-round(summary(TA_of)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  #ys <- max(Trends.inshore$TA_umol_kg, na.rm =T)
  ys <- max(Trends.offshore$TA_umol_kg, na.rm =T)
  plot_label <- sprintf("\"\" ~ TA == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Of_TA_Modeled<-Long_plot2+
     scale_y_continuous(limits = c(2250,2475),
                       name=(expression(paste("TA (", mu, "mol ",
                                              kg^-1, ")"))),
                       #breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.offshore, 
                               aes(y=TA_umol_kg, x=Date, 
                                  fill = Sub_region), 
                                  #colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=24)+
      geom_line(data=Of_TA_Pred, aes(y = Of_TA_Pred,
                                      x=Date, colour = Sub_region), linetype=1, size=1)+
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~TA[Ar] == -0.015** ~Year ^-1"),
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Of_TA_Modeled

Oceanic

hist(Trends.ocean$TA_umol_kg)

shapiro.test(Trends.ocean$TA_umol_kg)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$TA_umol_kg
## W = 0.9887, p-value = 0.2158
TA_oc_0<-lmer(TA_umol_kg ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)
  #summary(TA_oc_0)
  anova(TA_oc_0)
  ranova(TA_oc_0)
  step(TA_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                     9 -620.60 1259.2                         
## (1 | SiteID)          1    8 -620.60 1257.2  0.000  1   0.999965    
## (1 | Month)           0    7 -626.34 1266.7 11.479  1   0.000704 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1   36.60   18.30     2 147.47  0.1497 0.861116   
## Sub_region               2  240.91  120.45     2 149.14  0.9962 0.371707   
## Year                     0 1185.68 1185.68     1 157.86  9.7917 0.002088 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## TA_umol_kg ~ Year + (1 | Month)
TA_oc<-lmer(TA_umol_kg ~ Year + (1 | Month), data = Trends.ocean)
  summary(TA_oc)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: TA_umol_kg ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: 1253.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8967 -0.5606  0.1300  0.5822  2.6260 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  21.63    4.651  
##  Residual             121.09   11.004  
## Number of obs: 163, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error        df t value Pr(>|t|)   
## (Intercept) -557.2468   939.1753  157.8503  -0.593  0.55381   
## Year           1.4563     0.4654  157.8620   3.129  0.00209 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  anova(TA_oc)
plot(TA_oc)

  par(mfrow=c(1,2))
  qqnorm(resid(TA_oc))
  acf(resid(TA_oc), main="acf(resid(TA ocean))")

  par(mfrow=c(1,1))
  
Temp_oc.emmc<-emmeans(TA_oc, ~Year)
    #Temp_oc.emmc<-multcomp::cld(Temp_oc.emmc)
    #Temp_oc.emmc<-as.data.frame(Temp_in.emmc[complete.cases(Temp_in.emmc),])
    #Temp_oc.emmc<-Temp_oc.emmc[order(Temp_oc.emmc$Sub_region),]
    #Temp_oc.emmc
# Create a new data frame for independent variables  
  Oc_Newdata<-expand.grid(one=unique(Trends.ocean$Zone),
                                Sub_region=unique(Trends.ocean$Sub_region),
                          Year=seq((min(Trends.ocean$Year)-0), (max(Trends.ocean$Year)+1)))
  Oc_TA_Pred <- predict(TA_oc, newdata=Oc_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Oc_TA_Pred <-cbind(Oc_Newdata, Oc_TA_Pred)
  Oc_TA_Pred$Date<-as.Date(as.character(Oc_TA_Pred$Year), format = "%Y")
  
# Model summary for labels
  slope<-round(summary(TA_oc)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  #ys <- max(Trends.inshore$TA_umol_kg, na.rm =T)
  ys <- max(Trends.offshore$TA_umol_kg, na.rm =T)
  plot_label <- sprintf("\"\" ~ TA == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Oc_TA_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(limits = c(2250,2475),
                       name=(expression(paste("TA (", mu, "mol ",
                                              kg^-1, ")"))),
                       #breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.ocean, 
                               aes(y=TA_umol_kg, x=Date, 
                                   fill = Sub_region), 
                                   #colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=25)+
      geom_line(data=Oc_TA_Pred, aes(y = Oc_TA_Pred,
                                      x=Date), linetype=1, size=1, colour = "black") +
    
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~TA[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Oc_TA_Modeled

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.TA_in_0 <- data.frame (anova(TA_in_0))
    av.TA_mc_0 <- data.frame (anova(TA_mc_0) )
    av.TA_of_0 <- data.frame (anova(TA_of_0))
    av.TA_oc_0 <- data.frame (anova(TA_oc_0))
    
    # Putting all into one dataframe/table
    anova_TA_0 <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                                      rbind(av.TA_in_0, av.TA_mc_0,
                                            av.TA_of_0, av.TA_oc_0))) 
    colnames(anova_TA_0) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_TA_0) <- NULL
    
    # create HTML table using kableExtra
    anova_TA_0 %>% kable("html", digits=2, 
        caption="Initial TA models fixed factors: Year * Region") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "TA inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "TA mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "TA offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "TA ocean", 10, 12)  
Initial TA models fixed factors: Year * Region
Sum Sq Mean Sq N Df D Df F value Pr(>F)
TA inshore
Year 12144.36 12144.36 1 360.75 2.59 0.11
Sub_region 24071.88 8023.96 3 350.01 1.71 0.16
Year:Sub_region 24057.93 8019.31 3 350.01 1.71 0.16
TA mid-channel
Year 2234.07 2234.07 1 335.46 1.14 0.29
Sub_region 6343.28 2114.43 3 325.57 1.08 0.36
Year:Sub_region 6340.22 2113.41 3 325.57 1.08 0.36
TA offshore
Year 1575.10 1575.10 1 401.00 4.44 0.04
Sub_region 155.57 51.86 3 408.90 0.15 0.93
Year:Sub_region 154.60 51.53 3 408.90 0.15 0.93
TA ocean
Year 1082.81 1082.81 1 155.65 8.86 0.00
Sub_region 36.41 18.21 2 147.46 0.15 0.86
Year:Sub_region 36.60 18.30 2 147.47 0.15 0.86
# R-ANOVAs    
    rav.TA_in_0 <- data.frame (ranova(TA_in_0))
    rav.TA_mc_0 <- data.frame (ranova(TA_mc_0) )
    rav.TA_of_0 <- data.frame (ranova(TA_of_0))
    rav.TA_oc_0 <- data.frame (ranova(TA_oc_0))
    
    # Putting all into one dataframe/table
    ranova_TA_0 <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.TA_in_0, rav.TA_mc_0,
                            rav.TA_of_0, rav.TA_oc_0))) 
    colnames(ranova_TA_0) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_TA_0) <- NULL
    
    # create HTML table using kableExtra
    ranova_TA_0 %>% kable("html", digits=2,
         caption="Initial TA models random factors: Month+Station") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "TA inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "TA mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "TA offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "TA ocean", 10, 12)  
Initial TA models random factors: Month+Station
npar logLik AIC LRT DF Pr(>Chi Sq)
TA inshore
<none> 11 -2111.77 4245.54
(1 | Month) 10 -2187.98 4395.97 152.43 1 0.00
(1 | SiteID) 10 -2112.43 4244.86 1.32 1 0.25
TA mid-channel
<none> 11 -1817.11 3656.22
(1 | Month) 10 -1849.44 3718.87 64.66 1 0.00
(1 | SiteID) 10 -1818.69 3657.37 3.16 1 0.08
TA offshore
<none> 11 -1856.08 3734.16
(1 | Month) 10 -1878.53 3777.07 44.91 1 0.00
(1 | SiteID) 10 -1856.08 3732.16 0.00 1 1.00
TA ocean
<none> 9 -620.60 1259.19
(1 | Month) 8 -626.34 1268.67 11.48 1 0.00
(1 | SiteID) 8 -620.60 1257.19 0.00 1 1.00
TA_models_0<-list("Inshore" = TA_in_0, 
                   "Mid channel" = TA_mc_0, 
                   "Offshore" = TA_of_0, 
                   "Ocean" = TA_oc_0)
modelsummary(TA_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Initial TA model outputs (all factors)',
             coef_map=factor_order)
Initial TA model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year 1.046 0.873 0.560 1.525
(4.079) (2.661) (1.124) (1.002)
Intercept 266.963 616.762 1249.936 −695.348
(8230.631) (5370.342) (2267.304) (2021.206)
Upper Keys 555.392 2035.391 −1299.384
(10657.499) (7552.355) (2877.320)
Middle Keys −17995.335+ −8041.978 −1874.329 −355.634
(10334.207) (6699.927) (2851.984) (2388.676)
Lower Keys −1234.488 1139.413 −1257.505 674.419
(10357.074) (6732.364) (2707.705) (2401.637)
Num.Obs. 375 350 427 163
R2 Marg. 0.150 0.073 0.035 0.080
R2 Cond. 0.526 0.325
AIC 4245.5 3656.2 3734.2 1259.2
BIC 4288.7 3698.7 3778.8 1287.0
ICC 0.4 0.3
RMSE 66.44 42.86 18.44 10.59
+ p
#modelsummary(TA_models, estimate = "p.value")

Models with non-significant factors removed

TA_models<-list("Inshore" = TA_in, 
                   "Mid channel" = TA_mc, 
                   "Offshore" = TA_of, 
                   "Ocean" = TA_oc)
modelsummary(TA_models, stars = TRUE, 
            #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Final TA model outputs (dropped factors)',
             coef_map=factor_order)
Final TA model outputs (dropped factors)
Inshore Mid channel Offshore Ocean
Year 1.159* 1.456**
(0.512) (0.465)
Intercept 2377.997*** 2378.905*** 41.558 −557.247
(20.799) (9.320) (1032.895) (939.175)
Upper Keys 1.572 2.686 −0.539
(14.196) (7.773) (2.891)
Middle Keys −31.679* −15.174* −6.246*
(14.030) (6.879) (2.862)
Lower Keys −87.696*** −30.826*** −5.220+
(13.967) (6.846) (2.713)
Num.Obs. 375 350 427 163
R2 Marg. 0.137 0.062 0.030 0.059
R2 Cond. 0.526 0.303 0.169 0.202
AIC 4263.6 3668.8 3733.0 1261.8
BIC 4291.0 3692.0 3761.4 1274.2
ICC 0.5 0.3 0.1 0.2
RMSE 67.17 43.90 18.45 10.68
+ p
#modelsummary(TA_models, output = "FLK_results/Figures/Fig_2/Trend_TA.docx")
#modelsummary(TA_models, estimate = "p.value")
Trends_TA<-ggarrange(In_TA_Modeled+ theme(
                                          axis.text.x=element_blank(),
                                          legend.position = "none"),
                  Mc_TA_Modeled+ theme(legend.position = "none",
                                           axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                
                  Of_TA_Modeled + theme(legend.position = "none",
                                           axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                
                  Oc_TA_Modeled + theme(legend.position = "none",
                                           axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                           
          #labels = c("D"),
          ncol = 4, nrow = 1, widths =c(1.1, 1, 1, 1))
Trends_TA

DIC-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$DIC_umol_kg
## W = 0.90821, p-value < 2.2e-16

## Model with all data
DIC_all_o<-lmer(DIC_umol_kg~Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
  step(DIC_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik   AIC    LRT Df Pr(>Chisq)    
## <none>                    33 -7060.4 14187                         
## (1 | Month)           0   32 -7249.7 14563 378.55  1     <2e-16 ***
## (1 | SiteID)          0   32 -7061.8 14188   2.87  1       0.09 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated Sum Sq Mean Sq NumDF   DenDF F value  Pr(>F)  
## Year:Zone:Sub_region          1  14127  1765.9     8 1246.19  0.5634 0.80846  
## Year:Zone                     2   5542  1847.4     3 1254.02  0.5910 0.62092  
## Year:Sub_region               0  24810  8270.1     3 1257.35  2.6486 0.04761 *
## Zone:Sub_region               0  80360 10045.0     8   24.43  3.2170 0.01221 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + Zone + Sub_region + (1 | Month) + (1 | SiteID) + Year:Sub_region + Zone:Sub_region
DIC_all_1<-lmer(DIC_umol_kg ~ Year + Zone + Sub_region + 
                  (1 | Month) + (1 | SiteID) + 
                  Year:Sub_region + Zone:Sub_region, data=Trends.data)

    #summary(DIC_all_1)
    anova(DIC_all_1)
    ranova(DIC_all_1)
    plot(DIC_all_1)

      par(mfrow=c(1,2))
      qqnorm(resid(DIC_all_1))
      acf(resid(DIC_all_1), main="acf(resid(DIC all))")

      par(mfrow=c(1,1))
      
  m.lst <- lstrends(DIC_all_1, "Sub_region", var="Year")
  m.lst
##  Sub_region Year.trend   SE   df lower.CL upper.CL
##  BB               3.70 1.93 1261  -0.0861     7.48
##  UK               2.08 1.68 1266  -1.2243     5.38
##  MK               7.38 1.47 1263   4.4976    10.27
##  LK               2.86 1.44 1264   0.0290     5.70
## 
## Results are averaged over the levels of: Zone 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
  pairs(m.lst)
##  contrast estimate   SE   df t.ratio p.value
##  BB - UK     1.618 2.47 1257   0.655  0.9137
##  BB - MK    -3.685 2.33 1255  -1.581  0.3897
##  BB - LK     0.835 2.31 1255   0.362  0.9838
##  UK - MK    -5.304 2.14 1258  -2.482  0.0632
##  UK - LK    -0.783 2.11 1257  -0.371  0.9826
##  MK - LK     4.521 1.95 1256   2.317  0.0947
## 
## Results are averaged over the levels of: Zone 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 4 estimates

Inshore

# Inshore DIC
  hist(Trends.inshore$DIC_umol_kg)

  shapiro.test(Trends.inshore$DIC_umol_kg) # Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$DIC_umol_kg
## W = 0.99705, p-value = 0.7394
  DIC_in_0<-lmer(DIC_umol_kg~Year * Sub_region + (1|Month)+
                                    #(1|Zone)+             
                                    (1|SiteID), data=Trends.inshore)

  anova(DIC_in_0)
  step(DIC_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -2114.4 4250.7                          
## (1 | Month)           0   10 -2240.7 4501.3 252.580  1     <2e-16 ***
## (1 | SiteID)          0   10 -2116.5 4253.0   4.252  1     0.0392 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  25312    8437     3 347.82  1.7086 0.16492  
## Year                     0  31161   31161     1 358.72  6.2722 0.01271 *
## Sub_region               0  95613   31871     3   7.24  6.4151 0.01913 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + Sub_region + (1 | Month) + (1 | SiteID)
  summary(DIC_in_0)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year * Sub_region + (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 4228.7
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -3.15416 -0.67119  0.03094  0.64995  2.87897 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 6626     81.40   
##  SiteID   (Intercept)  220     14.83   
##  Residual             4938     70.27   
## Number of obs: 373, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##                     Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)       -4.304e+03  8.463e+03  3.498e+02  -0.509    0.611
## Year               3.153e+00  4.194e+00  3.498e+02   0.752    0.453
## Sub_regionUK       2.437e+03  1.095e+04  3.480e+02   0.223    0.824
## Sub_regionMK      -1.738e+04  1.061e+04  3.475e+02  -1.637    0.102
## Sub_regionLK      -2.786e+02  1.068e+04  3.475e+02  -0.026    0.979
## Year:Sub_regionUK -1.216e+00  5.426e+00  3.480e+02  -0.224    0.823
## Year:Sub_regionMK  8.590e+00  5.260e+00  3.475e+02   1.633    0.103
## Year:Sub_regionLK  1.042e-01  5.291e+00  3.475e+02   0.020    0.984
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK Sb_rLK Y:S_UK Y:S_MK
## Year        -1.000                                          
## Sub_reginUK -0.715  0.715                                   
## Sub_reginMK -0.739  0.739  0.569                            
## Sub_reginLK -0.730  0.730  0.565  0.582                     
## Yr:Sb_rgnUK  0.715 -0.715 -1.000 -0.569 -0.565              
## Yr:Sb_rgnMK  0.739 -0.739 -0.569 -1.000 -0.582  0.569       
## Yr:Sb_rgnLK  0.730 -0.730 -0.565 -0.582 -1.000  0.565  0.582
  DIC_in<-lmer(DIC_umol_kg ~ Year + Sub_region +
               (1 | Month) + (1 | SiteID),
                            data=Trends.inshore)
    anova(DIC_in)
    ranova(DIC_in)
    summary(DIC_in)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Sub_region + (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 4248.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.4161 -0.6586  0.0303  0.6553  2.7863 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 6626.4   81.40   
##  SiteID   (Intercept)  219.1   14.80   
##  Residual             4968.1   70.48   
## Number of obs: 373, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)   
## (Intercept)  -8737.835   4311.479   358.742  -2.027  0.04344 * 
## Year             5.350      2.136   358.720   2.504  0.01271 * 
## Sub_regionUK   -16.641     17.467     7.250  -0.953  0.37140   
## Sub_regionMK   -44.133     17.314     7.009  -2.549  0.03812 * 
## Sub_regionLK   -68.049     17.283     6.958  -3.937  0.00569 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.035  0.033              
## Sub_reginMK -0.010  0.008  0.588       
## Sub_reginLK -0.018  0.016  0.589  0.595
  plot(DIC_in)

    par(mfrow=c(1,2))
    qqnorm(resid(DIC_in))
    acf(resid(DIC_in), main="acf(resid(DIC Inshore))")

    par(mfrow=c(1,1))
  
  DIC_in.emmc<-emmeans(DIC_in, ~Sub_region)
    DIC_in.emmc<-multcomp::cld(DIC_in.emmc)
    #DIC_in.emmc<-as.data.frame(DIC_in.emmc[complete.cases(DIC_in.emmc),])
    DIC_in.emmc<-DIC_in.emmc[order(DIC_in.emmc$Sub_region),]
    DIC_in.emmc
  #write.csv(DIC_in.emmc, "FLK_results/DIC_in.emmc_POST.csv")
# Create a new data frame for independent variables  
  In_Newdata<-expand.grid(Sub_region=unique(Trends.inshore$Sub_region),
                          Year=seq((min(Trends.inshore$Year)-0),
                                   (max(Trends.inshore$Year)+1)))

  In_DIC_Pred <- predict(DIC_in, newdata=In_Newdata, 
                         re.form=NA, level=0, asList = FALSE)
  
  In_DIC_Pred <-cbind(In_Newdata, In_DIC_Pred)
  In_DIC_Pred$Date<-as.Date(as.character(In_DIC_Pred$Year), format = "%Y")
  
  # Model summary for labels
    slope<-round(summary(DIC_in)$coefficients["Year", "Estimate"], digits = 3)
    #xs <- as.Date(as.character("2018-11-20"))
    #ys <- max(Trends.inshore$TA_umol_kg, na.rm =T)
    ys <- max(Trends.inshore$DIC_umol_kg, na.rm =T)
    plot_label <- sprintf("\"\" ~ DIC == %0.3f", slope)
    plot_label2 <- expression("Year^-1")
  
  # Plot raw data point and fitted model 
  In_DIC_Modeled<-Long_plot2+ 
     scale_y_continuous(limits = c(1700,2320),
                       name=(expression(paste("DIC (", mu, "mol ",
                                              kg^-1, ")"))),
                       breaks = seq(1700,2320, 200),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.inshore, 
                               aes(y=DIC_umol_kg, x=Date, 
                                  fill = Sub_region), 
                                  #colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=21)+
      geom_line(data=In_DIC_Pred, aes(y = In_DIC_Pred,
                                      x=Date, colour = Sub_region), linetype=1, size=1)+
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  In_DIC_Modeled

Mid channel

hist(Trends.midchanel$DIC_umol_kg)

shapiro.test(Trends.midchanel$DIC_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$DIC_umol_kg
## W = 0.94836, p-value = 1.109e-09
DIC_mc_0<-lmer(DIC_umol_kg~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)

# DIC_mc_1<-lmer(DIC_umol_kg~Year * Sub_region * Season +
#                                     #(1|Zone)+             
#                                     (1|SiteID), data=Trends.midchanel)

#summary(DIC_mc_0)    
#summary(DIC_mc_1)  

anova(DIC_mc_0)
#anova(DIC_mc_1)
#anova(DIC_mc_0, DIC_mc_1)
ranova(DIC_mc_0)
step(DIC_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1833.5 3689.0                          
## (1 | SiteID)          1   10 -1834.1 3688.1   1.085  1     0.2975    
## (1 | Month)           0    9 -1891.7 3801.3 115.233  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1   8033  2677.6     3 329.04  1.1682 0.321879   
## Year                     0  11372 11371.7     1 342.72  4.9528 0.026698 * 
## Sub_region               0  34301 11433.8     3 332.14  4.9799 0.002156 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + Sub_region + (1 | Month)
DIC_mc<-lmer(DIC_umol_kg ~ Year + Sub_region + (1 | Month),
               data = Trends.midchanel)
  summary(DIC_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3684.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.2953 -0.4748  0.0154  0.5750  3.7927 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 1395     37.34   
##  Residual             2296     47.92   
## Number of obs: 348, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)  -4589.568   2984.771   342.723  -1.538 0.125054    
## Year             3.291      1.479   342.719   2.225 0.026698 *  
## Sub_regionUK    -7.413      8.314   332.145  -0.892 0.373229    
## Sub_regionMK   -21.935      7.358   332.068  -2.981 0.003083 ** 
## Sub_regionLK   -24.601      7.343   332.174  -3.350 0.000901 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.012  0.011              
## Sub_reginMK -0.002  0.000  0.530       
## Sub_reginLK -0.018  0.016  0.532  0.601
  anova(DIC_mc)
  plot(DIC_mc)

    par(mfrow=c(1,2))
    qqnorm(resid(DIC_mc))
    acf(resid(DIC_mc), main="acf(resid(DIC mid Channel))")  

    par(mfrow=c(1,1))
    
  DIC_md.emmc<-emmeans(DIC_mc, ~Sub_region)
    DIC_md.emmc<-multcomp::cld(DIC_md.emmc)
    #DIC_md.emmc<-as.data.frame(DIC_md.emmc[complete.cases(DIC_md.emmc),])
    DIC_md.emmc<-DIC_md.emmc[order(DIC_md.emmc$Sub_region),]
    DIC_md.emmc
  #write.csv(DIC_md.emmc, "FLK_results/Model_Temp_mc_POST.csv")
# Create a new data frame for independent variables  
  Mc_Newdata<-expand.grid(Sub_region=unique(Trends.midchanel$Sub_region),
                          Year=seq((min(Trends.midchanel$Year)-0),
                                   (max(Trends.midchanel$Year)+1)))

  Mc_DIC_Pred <- predict(DIC_mc, newdata=Mc_Newdata, 
                         re.form=NA, level=0, asList = FALSE)
  
  Mc_DIC_Pred <-cbind(Mc_Newdata, Mc_DIC_Pred)
  Mc_DIC_Pred$Date<-as.Date(as.character(Mc_DIC_Pred$Year), format = "%Y")
  
# Model summary for labels
    slope<-round(summary(DIC_mc)$coefficients["Year", "Estimate"], digits = 3)
    #xs <- as.Date(as.character("2018-11-20"))
    #ys <- max(Trends.inshore$TA_umol_kg, na.rm =T)
    ys <- max(Trends.inshore$DIC_umol_kg, na.rm =T)
    plot_label <- sprintf("\"\" ~ DIC == %0.3f", slope)
    plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Mc_DIC_Modeled<-Long_plot2+ 
     scale_y_continuous(limits = c(1700,2320),
                       name=(expression(paste("DIC (", mu, "mol ",
                                              kg^-1, ")"))),
                       breaks = seq(1700,2320, 200),  
                       expand = c(0.02, 0.02)) +
      geom_point(data=Trends.midchanel, 
                               aes(y=DIC_umol_kg, x=Date, 
                                  fill = Sub_region), 
                                  #colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=23)+
      geom_line(data=Mc_DIC_Pred, aes(y = Mc_DIC_Pred,
                                      x=Date, colour = Sub_region), linetype=1, size=1)+
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Mc_DIC_Modeled

Offshore

hist(Trends.offshore$DIC_umol_kg)

shapiro.test(Trends.offshore$DIC_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$DIC_umol_kg
## W = 0.95542, p-value = 4.729e-10
DIC_of_0<-lmer(DIC_umol_kg~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
#summary(DIC_of_0)    
anova(DIC_of_0)
ranova(DIC_of_0)
step(DIC_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC   LRT Df Pr(>Chisq)    
## <none>                    11 -1932.8 3887.7                        
## (1 | SiteID)          1   10 -1932.8 3885.7  0.00  1          1    
## (1 | Month)           0    9 -1963.0 3944.0 60.28  1  8.226e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1   806.3   268.8     3 407.55  0.5178   0.67026    
## Year                     0 23228.6 23228.6     1 411.35 44.9099 6.813e-11 ***
## Sub_region               0  4742.8  1580.9     3 410.76  3.0565   0.02825 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + Sub_region + (1 | Month)
DIC_of<-lmer(DIC_umol_kg ~ Year + Sub_region + (1 | Month), 
               data =Trends.offshore)
  summary(DIC_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3874.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.9981 -0.5363  0.1094  0.5639  2.6471 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 116.7    10.80   
##  Residual             517.2    22.74   
## Number of obs: 426, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)  -6415.8631  1263.6062   411.3193  -5.077 5.81e-07 ***
## Year             4.1960     0.6261   411.3550   6.701 6.81e-11 ***
## Sub_regionUK    -2.7095     3.5029   410.5267  -0.774   0.4397    
## Sub_regionMK    -8.5696     3.4683   410.5117  -2.471   0.0139 *  
## Sub_regionLK    -0.6895     3.2882   410.9233  -0.210   0.8340    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.004  0.002              
## Sub_reginMK -0.004  0.003  0.591       
## Sub_reginLK -0.013  0.011  0.625  0.632
  anova(DIC_of) 
plot(DIC_of)

  par(mfrow=c(1,2))
  qqnorm(resid(DIC_of))
  acf(resid(DIC_of), main="acf(resid(DIC offshore))")  

  par(mfrow=c(1,1))
    
  DIC_of.emmc<-emmeans(DIC_of, ~Sub_region)
    DIC_of.emmc<-multcomp::cld(DIC_of.emmc)
    #DIC_of.emmc<-as.data.frame(DIC_of.emmc[complete.cases(DIC_of.emmc),])
    DIC_of.emmc<-DIC_of.emmc[order(DIC_of.emmc$Sub_region),]
    DIC_of.emmc
#write.csv(DIC_of.emmc, "FLK_results/Model_DIC_of.emmc_POST.csv")
# Create a new data frame for independent variables  
  Of_Newdata<-expand.grid(#zone=unique(Trends.offshore$Zone),
                          Sub_region=unique(Trends.offshore$Sub_region),
                          Year=seq((min(Trends.offshore$Year)-0), (max(Trends.offshore$Year)+1)))
  Of_DIC_Pred <- predict(DIC_of, newdata=Of_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Of_DIC_Pred <-cbind(Of_Newdata, Of_DIC_Pred)
  Of_DIC_Pred$Date<-as.Date(as.character(Of_DIC_Pred$Year), format = "%Y")
  
# Model summary for labels
    slope<-round(summary(DIC_of)$coefficients["Year", "Estimate"], digits = 3)
    #xs <- as.Date(as.character("2018-11-20"))
    #ys <- max(Trends.inshore$TA_umol_kg, na.rm =T)
    ys <- max(Trends.offshore$DIC_umol_kg, na.rm =T)
    plot_label <- sprintf("\"\" ~ DIC == %0.3f", slope)
    plot_label2 <- expression("Year^-1")
    
# Plot raw data point and fitted model 
  Of_DIC_Modeled<-Long_plot2+
     scale_y_continuous(limits = c(1850,2200),
                       name=(expression(paste("DIC (", mu, "mol ",
                                              kg^-1, ")"))),
                       #breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.offshore, 
                               aes(y=DIC_umol_kg, x=Date, 
                                  fill = Sub_region), 
                                  #colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=24)+
      geom_line(data=Of_DIC_Pred, aes(y = Of_DIC_Pred,
                                      x=Date, colour = Sub_region), linetype=1, size=1)+
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~DIC[Ar] == -0.015** ~Year ^-1"),
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Of_DIC_Modeled

Oceanic

hist(Trends.ocean$DIC_umol_kg)

shapiro.test(Trends.ocean$DIC_umol_kg)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$DIC_umol_kg
## W = 0.97946, p-value = 0.01698
DIC_oc_0<-lmer(DIC_umol_kg ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)
  #summary(DIC_oc_0)
  anova(DIC_oc_0)
  ranova(DIC_oc_0)
  step(DIC_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)  
## <none>                     9 -684.21 1386.4                       
## (1 | SiteID)          1    8 -684.21 1384.4 0.0000  1    1.00000  
## (1 | Month)           0    7 -687.08 1388.2 5.7341  1    0.01664 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1   119.2    59.6     2 146.26  0.1898    0.8273    
## Sub_region               2   158.1    79.0     2 148.05  0.2546    0.7756    
## Year                     0 13827.2 13827.2     1 151.57 45.0044 3.671e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + (1 | Month)
DIC_oc<-lmer(DIC_umol_kg ~ Year + (1 | Month), data = Trends.ocean)
  summary(DIC_oc)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: 1383.4
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.54294 -0.63178 -0.03277  0.54011  2.77577 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  35.49    5.958  
##  Residual             307.24   17.528  
## Number of obs: 161, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept) -7873.046   1479.171   151.554  -5.323 3.62e-07 ***
## Year            4.917      0.733   151.572   6.709 3.67e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  anova(DIC_oc)
plot(DIC_oc)

  par(mfrow=c(1,2))
  qqnorm(resid(DIC_oc))
  acf(resid(DIC_oc), main="acf(resid(DIC ocean))")

  par(mfrow=c(1,1))
  
Temp_oc.emmc<-emmeans(DIC_oc, ~Year)
    #Temp_oc.emmc<-multcomp::cld(Temp_oc.emmc)
    #Temp_oc.emmc<-as.data.frame(Temp_in.emmc[complete.cases(Temp_in.emmc),])
    #Temp_oc.emmc<-Temp_oc.emmc[order(Temp_oc.emmc$Sub_region),]
    #Temp_oc.emmc
# Create a new data frame for independent variables  
  Oc_Newdata<-expand.grid(#zone=unique(Trends.ocean$Zone),
                          Sub_region=unique(Trends.ocean$Sub_region),
                          Year=seq((min(Trends.ocean$Year)-0), (max(Trends.ocean$Year)+1)))
  Oc_DIC_Pred <- predict(DIC_oc, newdata=Oc_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Oc_DIC_Pred <-cbind(Oc_Newdata, Oc_DIC_Pred)
  Oc_DIC_Pred$Date<-as.Date(as.character(Oc_DIC_Pred$Year), format = "%Y")
  
# Model summary for labels
  slope<-round(summary(DIC_oc)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  #ys <- max(Trends.inshore$DIC_umol_kg, na.rm =T)
  ys <- max(Trends.offshore$DIC_umol_kg, na.rm =T)
  plot_label <- sprintf("\"\" ~ DIC == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Oc_DIC_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(limits = c(1850,2200),
                       name=(expression(paste("DIC (", mu, "mol ",
                                              kg^-1, ")"))),
                       #breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.ocean, 
                               aes(y=DIC_umol_kg, x=Date, 
                                   fill = Sub_region), 
                                   #colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=25)+
      geom_line(data=Oc_DIC_Pred, aes(y = Oc_DIC_Pred,
                                      x=Date), linetype=1, size=1, colour = "black") +
    
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~DIC[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Oc_DIC_Modeled

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.DIC_in_0 <- data.frame (anova(DIC_in_0))
    av.DIC_mc_0 <- data.frame (anova(DIC_mc_0) )
    av.DIC_of_0 <- data.frame (anova(DIC_of_0))
    av.DIC_oc_0 <- data.frame (anova(DIC_oc_0))
    
    # Putting all into one dataframe/table
    anova_DIC_0 <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                                      rbind(av.DIC_in_0, av.DIC_mc_0,
                                            av.DIC_of_0, av.DIC_oc_0))) 
    colnames(anova_DIC_0) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_DIC_0) <- NULL
    
    # create HTML table using kableExtra
    anova_DIC_0 %>% kable("html", digits=2, 
        caption="Initial DIC models fixed factors: Year * Region") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "DIC inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "DIC mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "DIC offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "DIC ocean", 10, 12)  
Initial DIC models fixed factors: Year * Region
Sum Sq Mean Sq N Df D Df F value Pr(>F)
DIC inshore
Year 27064.82 27064.82 1 355.55 5.48 0.02
Sub_region 25355.56 8451.85 3 347.82 1.71 0.16
Year:Sub_region 25312.45 8437.48 3 347.82 1.71 0.16
DIC mid-channel
Year 10118.41 10118.41 1 334.22 4.47 0.04
Sub_region 8098.96 2699.65 3 323.72 1.19 0.31
Year:Sub_region 8099.20 2699.73 3 323.72 1.19 0.31
DIC offshore
Year 22497.95 22497.95 1 410.03 43.34 0.00
Sub_region 810.06 270.02 3 407.57 0.52 0.67
Year:Sub_region 806.25 268.75 3 407.57 0.52 0.67
DIC ocean
Year 12846.12 12846.12 1 150.10 40.92 0.00
Sub_region 119.46 59.73 2 146.26 0.19 0.83
Year:Sub_region 119.18 59.59 2 146.26 0.19 0.83
# R-ANOVAs    
    rav.DIC_in_0 <- data.frame (ranova(DIC_in_0))
    rav.DIC_mc_0 <- data.frame (ranova(DIC_mc_0) )
    rav.DIC_of_0 <- data.frame (ranova(DIC_of_0))
    rav.DIC_oc_0 <- data.frame (ranova(DIC_oc_0))
    
    # Putting all into one dataframe/table
    ranova_DIC_0 <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.DIC_in_0, rav.DIC_mc_0,
                            rav.DIC_of_0, rav.DIC_oc_0))) 
    colnames(ranova_DIC_0) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_DIC_0) <- NULL
    
    # create HTML table using kableExtra
    ranova_DIC_0 %>% kable("html", digits=2,
         caption="Initial DIC models random factors: Month+Station") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "DIC inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "DIC mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "DIC offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "DIC ocean", 10, 12)  
Initial DIC models random factors: Month+Station
npar logLik AIC LRT DF Pr(>Chi Sq)
DIC inshore
<none> 11 -2114.37 4250.73
(1 | Month) 10 -2240.66 4501.32 252.58 1 0.00
(1 | SiteID) 10 -2116.49 4252.99 4.25 1 0.04
DIC mid-channel
<none> 11 -1833.51 3689.03
(1 | Month) 10 -1891.61 3803.21 116.19 1 0.00
(1 | SiteID) 10 -1834.06 3688.11 1.09 1 0.30
DIC offshore
<none> 11 -1932.85 3887.71
(1 | Month) 10 -1962.99 3945.99 60.28 1 0.00
(1 | SiteID) 10 -1932.85 3885.71 0.00 1 1.00
DIC ocean
<none> 9 -684.21 1386.42
(1 | Month) 8 -687.08 1390.16 5.73 1 0.02
(1 | SiteID) 8 -684.21 1384.42 0.00 1 1.00
DIC_models_0<-list("Inshore" = DIC_in_0, 
                   "Mid channel" = DIC_mc_0, 
                   "Offshore" = DIC_of_0, 
                   "Ocean" = DIC_oc_0)
modelsummary(DIC_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Initial DIC model outputs (all factors)',
             coef_map=factor_order)
Initial DIC model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year 3.153 3.137 3.928** 5.502***
(4.194) (2.869) (1.362) (1.597)
Intercept −4304.442 −4277.474 −5874.354* −9054.180**
(8463.305) (5790.612) (2748.042) (3222.872)
Upper Keys 2437.232 922.158 −352.771
(10947.933) (8121.751) (3482.088)
Middle Keys −17377.771 −6709.675 −2783.437 832.763
(10613.801) (7205.660) (3451.382) (3823.319)
Lower Keys −278.558 5516.448 753.021 2203.941
(10677.024) (7268.930) (3286.325) (3861.141)
Num.Obs. 373 348 426 161
R2 Marg. 0.066 0.043 0.141 0.248
R2 Cond. 0.609 0.417
AIC 4250.7 3689.0 3887.7 1386.4
BIC 4293.9 3731.4 3932.3 1414.2
ICC 0.6 0.4
RMSE 68.08 46.12 22.31 17.03
+ p
#modelsummary(DIC_models, estimate = "p.value")

Models with non-significant factors removed

DIC_models<-list("Inshore" = DIC_in, 
                   "Mid channel" = DIC_mc, 
                   "Offshore" = DIC_of, 
                   "Ocean" = DIC_oc)
modelsummary(DIC_models, stars = TRUE, 
            #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Final DIC model outputs (dropped factors)',
             coef_map=factor_order)
Final DIC model outputs (dropped factors)
Inshore Mid channel Offshore Ocean
Year 5.350* 3.291* 4.196*** 4.917***
(2.136) (1.479) (0.626) (0.733)
Intercept −8737.835* −4589.568 −6415.863*** −7873.046***
(4311.479) (2984.771) (1263.606) (1479.171)
Upper Keys −16.641 −7.413 −2.710
(17.467) (8.314) (3.503)
Middle Keys −44.133* −21.935** −8.570*
(17.314) (7.358) (3.468)
Lower Keys −68.049*** −24.601*** −0.690
(17.283) (7.343) (3.288)
Num.Obs. 373 348 426 161
R2 Marg. 0.061 0.038 0.116 0.230
R2 Cond. 0.605 0.401 0.279 0.309
AIC 4264.5 3698.2 3888.8 1391.4
BIC 4295.8 3725.2 3917.2 1403.7
ICC 0.6 0.4 0.2 0.1
RMSE 68.58 46.85 22.35 17.06
+ p
#modelsummary(DIC_models, output = "FLK_results/Figures/Fig_2/Trend_DIC.docx")
#modelsummary(DIC_models, estimate = "p.value")
Trends_DIC<-ggarrange(In_DIC_Modeled+ theme(
                                          #axis.text.x=element_blank(),
                                          legend.position = "none"),
                  Mc_DIC_Modeled+ theme(legend.position = "none",
                                           #axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                
                  Of_DIC_Modeled + theme(legend.position = "none",
                                           #axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                
                  Oc_DIC_Modeled + theme(legend.position = "none",
                                           #axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                           
          #labels = c("E"),
          ncol = 4, nrow = 1, widths =c(1.1, 1, 1, 1))
Trends_DIC

Omega-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$Aragonite_Sat_W
## W = 0.97568, p-value = 4.918e-14

## Model with all data
Omega_all_o<-lmer(Aragonite_Sat_W~Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
  step(Omega_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                    33 -319.09  704.18                         
## (1 | SiteID)          1   32 -319.34  702.67   0.49  1     0.4849    
## (1 | Month)           0   31 -506.30 1074.59 373.92  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)
## Year:Zone:Sub_region          1 0.1753 0.02192     8 1265.1  0.2644  0.97717
## Year:Sub_region               2 0.1009 0.03364     3 1273.3  0.4077  0.74747
## Year:Zone                     0 0.6658 0.22195     3 1276.1  2.6936  0.04482
## Zone:Sub_region               0 5.4769 0.68461     8 1276.1  8.3088 4.94e-11
##                         
## Year:Zone:Sub_region    
## Year:Sub_region         
## Year:Zone            *  
## Zone:Sub_region      ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone + Zone:Sub_region
Omega_all_1<-lmer(Aragonite_Sat_W ~ Year + Zone + Sub_region + (1 | Month) +
                      Year:Zone + Zone:Sub_region, data=Trends.data)

Omega_all_3<-lmer(Aragonite_Sat_W ~ Year + Zone + (1 | Month) + (1|Sub_region)+
                       Year:Zone, data=Trends.data)
    

anova(Omega_all_1, Omega_all_3)
    summary(Omega_all_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: 
## Aragonite_Sat_W ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone +  
##     Zone:Sub_region
##    Data: Trends.data
## 
## REML criterion at convergence: 575.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.6656 -0.5694  0.0463  0.5720  5.0564 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.03497  0.187   
##  Residual             0.08240  0.287   
## Number of obs: 1306, groups:  Month, 12
## 
## Fixed effects:
##                                Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                   1.490e+01  1.560e+01  1.284e+03   0.955 0.339581
## Year                         -5.593e-03  7.731e-03  1.284e+03  -0.723 0.469543
## ZoneMid channel               1.716e+01  2.128e+01  1.276e+03   0.806 0.420124
## ZoneOffshore                  4.646e+01  2.027e+01  1.276e+03   2.292 0.022080
## ZoneOceanic                   6.184e+01  2.675e+01  1.276e+03   2.312 0.020945
## Sub_regionUK                  2.151e-01  4.496e-02  1.276e+03   4.784 1.92e-06
## Sub_regionMK                  9.895e-02  4.403e-02  1.276e+03   2.247 0.024790
## Sub_regionLK                 -2.573e-01  4.378e-02  1.276e+03  -5.876 5.36e-09
## Year:ZoneMid channel         -8.460e-03  1.055e-02  1.276e+03  -0.802 0.422573
## Year:ZoneOffshore            -2.295e-02  1.005e-02  1.276e+03  -2.285 0.022481
## Year:ZoneOceanic             -3.044e-02  1.325e-02  1.276e+03  -2.297 0.021795
## ZoneMid channel:Sub_regionUK -1.016e-01  6.705e-02  1.276e+03  -1.515 0.129982
## ZoneOffshore:Sub_regionUK    -1.850e-01  6.305e-02  1.276e+03  -2.934 0.003403
## ZoneOceanic:Sub_regionUK     -4.041e-01  7.599e-02  1.276e+03  -5.318 1.24e-07
## ZoneMid channel:Sub_regionMK -3.360e-02  6.225e-02  1.276e+03  -0.540 0.589463
## ZoneOffshore:Sub_regionMK    -8.265e-02  6.206e-02  1.276e+03  -1.332 0.183203
## ZoneOceanic:Sub_regionMK     -3.155e-01  6.396e-02  1.276e+03  -4.933 9.18e-07
## ZoneMid channel:Sub_regionLK  1.714e-01  6.195e-02  1.276e+03   2.767 0.005738
## ZoneOffshore:Sub_regionLK     2.059e-01  6.029e-02  1.276e+03   3.415 0.000658
##                                 
## (Intercept)                     
## Year                            
## ZoneMid channel                 
## ZoneOffshore                 *  
## ZoneOceanic                  *  
## Sub_regionUK                 ***
## Sub_regionMK                 *  
## Sub_regionLK                 ***
## Year:ZoneMid channel            
## Year:ZoneOffshore            *  
## Year:ZoneOceanic             *  
## ZoneMid channel:Sub_regionUK    
## ZoneOffshore:Sub_regionUK    ** 
## ZoneOceanic:Sub_regionUK     ***
## ZoneMid channel:Sub_regionMK    
## ZoneOffshore:Sub_regionMK       
## ZoneOceanic:Sub_regionMK     ***
## ZoneMid channel:Sub_regionLK ** 
## ZoneOffshore:Sub_regionLK    ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## fit warnings:
## fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
    anova(Omega_all_1)
    ranova(Omega_all_1)
# Obtain slopes
    #ranef(Omega_all_1)
    #fixef(Omega_all_1)
    #coef(Omega_all_1)$Month
    #coef(Omega_all_1)$Zone

  m.lst <- lstrends(Omega_all_1, "Zone", var="Year")
  m.lst
##  Zone        Year.trend      SE   df lower.CL upper.CL
##  Inshore       -0.00559 0.00774 1284  -0.0208  0.00958
##  Mid channel   -0.01405 0.00798 1284  -0.0297  0.00160
##  Offshore      -0.02855 0.00729 1284  -0.0428 -0.01424
##  Oceanic       -0.03604 0.01129 1280  -0.0582 -0.01388
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
  pairs(m.lst)
##  contrast               estimate     SE   df t.ratio p.value
##  Inshore - Mid channel   0.00846 0.0105 1276   0.802  0.8534
##  Inshore - Offshore      0.02295 0.0100 1276   2.285  0.1021
##  Inshore - Oceanic       0.03044 0.0133 1276   2.297  0.0993
##  Mid channel - Offshore  0.01449 0.0102 1276   1.416  0.4895
##  Mid channel - Oceanic   0.02198 0.0134 1276   1.641  0.3560
##  Offshore - Oceanic      0.00749 0.0130 1276   0.576  0.9393
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 4 estimates

Inshore

# Inshore Omega
  hist(Trends.inshore$Aragonite_Sat_W)

  shapiro.test(Trends.inshore$Aragonite_Sat_W) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$Aragonite_Sat_W
## W = 0.98599, p-value = 0.001134
  Omega_in_0<-lmer(Aragonite_Sat_W~Year * Sub_region + (1|Month)+
                                    #(1|Zone)+             
                                    (1|SiteID), data=Trends.inshore)
  
  Omega_in_1<-lmer(Aragonite_Sat_W~Year * Sub_region * Season +
                                    #(1|Zone)+             
                                    (1|SiteID), data=Trends.inshore)
  
  #summary(Omega_in_0)
  #summary(Omega_in_1)    
  #anova(Omega_in_0, Omega_in_1)
  #step(Omega_in_1)
  
  anova(Omega_in_0)
  ranova(Omega_in_0)
  step(Omega_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -158.47 338.94                         
## (1 | SiteID)          1   10 -159.74 339.47   2.53  1     0.1117    
## (1 | Month)           0    9 -292.29 602.58 265.11  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)    
## Year:Sub_region          1  0.0569  0.0190     3 354.17  0.1691 0.9172    
## Year                     2  0.1096  0.1096     1 364.53  0.9841 0.3218    
## Sub_region               0 10.9897  3.6632     3 358.15 32.8925 <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Sub_region + (1 | Month)
  Omega_in<-lmer(Aragonite_Sat_W ~ Sub_region + (1 | Month),
                 data=Trends.inshore)
  anova(Omega_in)
  summary(Omega_in)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Aragonite_Sat_W ~ Sub_region + (1 | Month)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 296.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8609 -0.5681  0.0603  0.5554  4.0778 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.1496   0.3868  
##  Residual             0.1114   0.3337  
## Number of obs: 373, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)    3.63208    0.11850  13.30859  30.651 9.81e-14 ***
## Sub_regionUK   0.20027    0.05227 358.12645   3.832  0.00015 ***
## Sub_regionMK   0.09924    0.05124 358.13089   1.937  0.05359 .  
## Sub_regionLK  -0.24632    0.05098 358.14454  -4.831 2.02e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.247              
## Sub_reginMK -0.253  0.571       
## Sub_reginLK -0.255  0.572  0.587
  plot(Omega_in)

  par(mfrow=c(1,1))
  qqnorm(resid(Omega_in))

  acf(resid(Omega_in), main="acf(resid(Omega Inshore))")

  par(mfrow=c(1,1))
  
  Arg_in.emmc<-emmeans(Omega_in, ~Sub_region)
    Arg_in.emmc<-multcomp::cld(Arg_in.emmc)
    #Arg_in.emmc<-as.data.frame(Arg_in.emmc[complete.cases(Arg_in.emmc),])
    Arg_in.emmc<-Arg_in.emmc[order(Arg_in.emmc$Sub_region),]
    Arg_in.emmc
  #write.csv(Arg_in.emmc, "FLK_results/Model_9_LTpH_POST.csv")
    round(Arg_in.emmc$emmean, digits = 2)
## [1] 3.63 3.83 3.73 3.39
  #anova(Omega_in)
  #ranova(Omega_in)
# Create a new data frame for independent variables  
  In_Newdata<-expand.grid(Zone=unique(Trends.inshore$Zone),
                          Sub_region=unique(Trends.inshore$Sub_region),
                          Year=seq((min(Trends.inshore$Year)-0), (max(Trends.inshore$Year)+1)))
  In_Omega_Pred <- predict(Omega_in, newdata=In_Newdata, re.form=NA, level=0, asList = FALSE)
  
  In_Omega_Pred <-cbind(In_Newdata, In_Omega_Pred)
  In_Omega_Pred$Date<-as.Date(as.character(In_Omega_Pred$Year), format = "%Y")
  
  
# Plot raw data point and fitted model 
  
  In_Omega_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(0,6),
                       #name=(expression("Aragonite saturation state" ~(Omega[Ar]))),
                       name=(expression(~Omega[Ar])),
                       limits = c(2.3, 5.2),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.inshore, 
                               aes(y=Aragonite_Sat_W, x=Date, 
                                  fill = Sub_region), 
                                  #colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=21)+
      geom_line(data=In_Omega_Pred, aes(y = In_Omega_Pred,
                                      x=Date, colour = Sub_region), linetype=2, size=1) 
  In_Omega_Modeled

Mid channel

hist(Trends.midchanel$Aragonite_Sat_W)

shapiro.test(Trends.midchanel$Aragonite_Sat_W)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$Aragonite_Sat_W
## W = 0.98399, p-value = 0.0006581
Omega_mc_0<-lmer(Aragonite_Sat_W~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)

# Omega_mc_1<-lmer(Aragonite_Sat_W~Year * Sub_region * Season +
#                                     #(1|Zone)+             
#                                     (1|SiteID), data=Trends.midchanel)

    #summary(Omega_mc_0)    
    #summary(Omega_mc_1)  
    
    anova(Omega_mc_0)
    #anova(Omega_mc_1)
    #anova(Omega_mc_0, Omega_mc_1)
    ranova(Omega_mc_0)
    step(Omega_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar   logLik     AIC     LRT Df Pr(>Chisq)    
## <none>                    11  -33.105  88.211                          
## (1 | SiteID)          1   10  -33.637  87.274   1.063  1     0.3025    
## (1 | Month)           0    9 -102.380 222.760 137.486  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1 0.12890 0.04297     3 329.13  0.7493   0.52339    
## Year                     0 0.24196 0.24196     1 342.10  4.2296   0.04048 *  
## Sub_region               0 1.99759 0.66586     3 332.22 11.6397 2.849e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Year + Sub_region + (1 | Month)
Omega_mc<-lmer(Aragonite_Sat_W ~ Year + Sub_region + (1 | Month),
               data = Trends.midchanel)
  summary(Omega_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Aragonite_Sat_W ~ Year + Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 50.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.2542 -0.5546  0.0284  0.5818  3.4212 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.04181  0.2045  
##  Residual             0.05721  0.2392  
## Number of obs: 348, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)   
## (Intercept)   34.412104  14.931233 342.106233   2.305  0.02178 * 
## Year          -0.015216   0.007399 342.099332  -2.057  0.04048 * 
## Sub_regionUK   0.115884   0.041502 332.216472   2.792  0.00554 **
## Sub_regionMK   0.065034   0.036727 332.152378   1.771  0.07752 . 
## Sub_regionLK  -0.085215   0.036655 332.240537  -2.325  0.02069 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.012  0.011              
## Sub_reginMK -0.002  0.000  0.530       
## Sub_reginLK -0.018  0.016  0.532  0.601
  anova(Omega_mc) 
  plot(Omega_mc)

  par(mfrow=c(1,2))
  qqnorm(resid(Omega_mc))
  acf(resid(Omega_mc), main="acf(resid(Omega mid Channel))")  

  par(mfrow=c(1,1))
  
  Arg_md.emmc<-emmeans(Omega_mc, ~Sub_region+Year)
    Arg_md.emmc<-multcomp::cld(Arg_md.emmc)
    #Arg_in.emmc<-as.data.frame(Arg_in.emmc[complete.cases(Arg_in.emmc),])
    Arg_md.emmc<-Arg_md.emmc[order(Arg_md.emmc$Sub_region),]
    Arg_md.emmc
  #write.csv(Arg_md.emmc, "FLK_results/Model_10_LTpH_POST.csv")
# Create a new data frame for independent variables  
  Mc_Newdata<-expand.grid(Zone=unique(Trends.midchanel$Zone),
                                Sub_region=unique(Trends.midchanel$Sub_region),
                          Year=seq((min(Trends.midchanel$Year)-0), (max(Trends.midchanel$Year)+1)))
  Mc_Omega_Pred <- predict(Omega_mc, newdata=Mc_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Mc_Omega_Pred <-cbind(Mc_Newdata, Mc_Omega_Pred)
  Mc_Omega_Pred$Date<-as.Date(as.character(Mc_Omega_Pred$Year), format = "%Y")
  
  
# Model summary for labels
  slope<-round(
      summary(Omega_mc)$coefficients["Year", "Estimate"], digits = 3)
  ys <- max(Trends.midchanel$Aragonite_Sat_W, na.rm =T)+ 0.3

# Plot raw data point and fitted model 
  plot_label <- sprintf("\"\" ~ Omega[Ar] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
  Mc_Omega_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(15,40),
                       #name=(expression("Aragonite saturation state" ~(Omega[Ar]))),
                       name=(expression(~Omega[Ar])),
                       limits = c(2.3, 5.2),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_jitter(data=Trends.midchanel, 
                               aes(y=Aragonite_Sat_W, x=Date, 
                                  fill = Sub_region), 
                                  #colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=23)+
      geom_line(data=Mc_Omega_Pred, aes(y = Mc_Omega_Pred,
                                      x=Date, colour = Sub_region), linetype=1, size=1)+
      # geom_text(data = slope, aes(x = xs, y = ys,
      #                       label = (paste("~Omega[Ar]", "=", 
      #                                     slope, "Year ^-1"))), size=10)
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Mc_Omega_Modeled

Offshore

hist(Trends.offshore$Aragonite_Sat_W)

shapiro.test(Trends.offshore$Aragonite_Sat_W)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$Aragonite_Sat_W
## W = 0.99121, p-value = 0.0128
Omega_of_0<-lmer(Aragonite_Sat_W~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
#summary(Omega_of_0)    
anova(Omega_of_0)
ranova(Omega_of_0)
step(Omega_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik     AIC     LRT Df Pr(>Chisq)    
## <none>                    11 153.652 -285.30                          
## (1 | SiteID)          1   10 153.486 -286.97   0.332  1     0.5644    
## (1 | Month)           0    9  86.497 -154.99 133.977  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1 0.04838 0.01613     3 404.94  0.6907    0.5581    
## Year                     0 0.98863 0.98863     1 418.90 42.4403 2.093e-10 ***
## Sub_region               0 0.55609 0.18536     3 408.08  7.9574 3.619e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Year + Sub_region + (1 | Month)
Omega_of<-lmer(Aragonite_Sat_W ~ Year + Sub_region + (1 | Month), 
               data =Trends.offshore)
  summary(Omega_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Aragonite_Sat_W ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: -327.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.8494 -0.6878  0.0746  0.6305  3.5033 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.01341  0.1158  
##  Residual             0.02329  0.1526  
## Number of obs: 424, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)   59.846389   8.611290 418.898403   6.950 1.41e-11 ***
## Year          -0.027797   0.004267 418.895440  -6.515 2.09e-10 ***
## Sub_regionUK   0.019509   0.023509 407.966516   0.830  0.40710    
## Sub_regionMK   0.017049   0.023277 407.960709   0.732  0.46432    
## Sub_regionLK  -0.062086   0.022129 408.171391  -2.806  0.00526 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.004  0.002              
## Sub_reginMK -0.005  0.003  0.591       
## Sub_reginLK -0.013  0.012  0.623  0.630
  anova(Omega_of) 
  plot(Omega_of)

  par(mfrow=c(1,2))
  qqnorm(resid(Omega_of))
  acf(resid(Omega_of), main="acf(resid(Omega offshore))")  

  par(mfrow=c(1,1))
  
  Arg_of.emmc<-emmeans(Omega_of, ~Sub_region+Year)
    Arg_of.emmc<-multcomp::cld(Arg_of.emmc)
    #Arg_in.emmc<-as.data.frame(Arg_in.emmc[complete.cases(Arg_in.emmc),])
    Arg_of.emmc<-Arg_of.emmc[order(Arg_of.emmc$Sub_region),]
    Arg_of.emmc
#write.csv(Arg_of.emmc, "FLK_results/Model_11_LTpH_POST.csv")
# Create a new data frame for independent variables  
  Of_Newdata<-expand.grid(one=unique(Trends.offshore$Zone),
                                Sub_region=unique(Trends.offshore$Sub_region),
                          Year=seq((min(Trends.offshore$Year)-0), (max(Trends.offshore$Year)+1)))
  Of_Omega_Pred <- predict(Omega_of, newdata=Of_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Of_Omega_Pred <-cbind(Of_Newdata, Of_Omega_Pred)
  Of_Omega_Pred$Date<-as.Date(as.character(Of_Omega_Pred$Year), format = "%Y")
  
# Model summary for labels
  slope<-round(summary(Omega_of)$coefficients["Year", "Estimate"], digits = 3)
  ys <- max(Trends.offshore$Aragonite_Sat_W, na.rm =T)
  plot_label <- sprintf("\"\" ~ Omega[Ar] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Of_Omega_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(15,40),
                       #name=(expression("Aragonite saturation state" ~(Omega[Ar]))),
                      name=(expression(~Omega[Ar])),
                       limits = c(3, 4.5),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.offshore, 
                               aes(y=Aragonite_Sat_W, x=Date, 
                                  fill = Sub_region), 
                                  #colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=24)+
      geom_line(data=Of_Omega_Pred, aes(y = Of_Omega_Pred,
                                      x=Date, colour = Sub_region), linetype=1, size=1)+
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Of_Omega_Modeled

Oceanic

hist(Trends.ocean$Aragonite_Sat_W)

shapiro.test(Trends.ocean$Aragonite_Sat_W)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$Aragonite_Sat_W
## W = 0.9889, p-value = 0.2355
Omega_oc_0<-lmer(Aragonite_Sat_W ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)

Omega_oc_1<-lmer(Aragonite_Sat_W ~ Year * Sub_region * Season++ (1|SiteID),
               data=Trends.ocean)
  #summary(Omega_oc_0)
  #summary(Omega_oc_1)    
  #anova(Omega_oc_1) 
  anova(Omega_oc_0)
  ranova(Omega_oc_0)
  step(Omega_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                     9 57.434 -96.867                         
## (1 | SiteID)          1    8 57.434 -98.867  0.000  1          1    
## (1 | Month)           0    7 28.818 -43.635 57.232  1  3.873e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1 0.00575 0.00287     2 144.13  0.1464    0.8640    
## Sub_region               2 0.06918 0.03459     2 146.00  1.7828    0.1718    
## Year                     0 0.54008 0.54008     1 156.35 27.5477 4.925e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Year + (1 | Month)
Omega_oc<-lmer(Aragonite_Sat_W ~ Year + (1 | Month), data = Trends.ocean)
  summary(Omega_oc)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Aragonite_Sat_W ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: -135.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.4346 -0.6808  0.0680  0.5175  2.4440 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.01649  0.1284  
##  Residual             0.01961  0.1400  
## Number of obs: 161, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)  69.402759  12.504422 156.361546   5.550 1.19e-07 ***
## Year         -0.032522   0.006196 156.354492  -5.249 4.92e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  anova(Omega_oc)
  plot(Omega_oc)

  par(mfrow=c(1,2))
  qqnorm(resid(Omega_oc))
  acf(resid(Omega_oc), main="acf(resid(Omega open))")

  par(mfrow=c(1,1))
  
  Arg_oc.emmc<-emmeans(Omega_oc, ~Year)
    #Arg_oc.emmc<-multcomp::cld(Arg_oc.emmc)
    #Arg_oc.emmc<-as.data.frame(Arg_in.emmc[complete.cases(Arg_in.emmc),])
    #Arg_oc.emmc<-Arg_oc.emmc[order(Arg_oc.emmc$Sub_region),]
    #Arg_oc.emmc
# Create a new data frame for independent variables  
  Oc_Newdata<-expand.grid(one=unique(Trends.ocean$Zone),
                                Sub_region=unique(Trends.ocean$Sub_region),
                          Year=seq((min(Trends.ocean$Year)-0), (max(Trends.ocean$Year)+1)))
  Oc_Omega_Pred <- predict(Omega_oc, newdata=Oc_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Oc_Omega_Pred <-cbind(Oc_Newdata, Oc_Omega_Pred)
  Oc_Omega_Pred$Date<-as.Date(as.character(Oc_Omega_Pred$Year), format = "%Y")
  
# Model summary for labels
  slope<-round(summary(Omega_oc)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  #ys <- max(Trends.inshore$Aragonite_Sat_W, na.rm =T)
  ys <- max(Trends.offshore$Aragonite_Sat_W, na.rm =T)
  plot_label <- sprintf("\"\" ~ Omega[Ar] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  
  Oc_Omega_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(15,40),
                       #name=(expression("Aragonite saturation state" ~(Omega[Ar]))),
                      name=(expression(~Omega[Ar])),
                       limits = c(3, 4.5),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.ocean, 
                               aes(y=Aragonite_Sat_W, x=Date, 
                                   fill = Sub_region), 
                                   #colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=25)+
      geom_line(data=Oc_Omega_Pred, aes(y = Oc_Omega_Pred,
                                      x=Date), linetype=1, size=1, colour = "black") +
    
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Oc_Omega_Modeled

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.Omega_in_0 <- data.frame (anova(Omega_in_0))
    av.Omega_mc_0 <- data.frame (anova(Omega_mc_0) )
    av.Omega_of_0 <- data.frame (anova(Omega_of_0))
    av.Omega_oc_0 <- data.frame (anova(Omega_oc_0))
    
    # Putting all into one dataframe/table
    anova_Omega_0 <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                                      rbind(av.Omega_in_0, av.Omega_mc_0,
                                            av.Omega_of_0, av.Omega_oc_0))) 
    colnames(anova_Omega_0) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_Omega_0) <- NULL
    
    # create HTML table using kableExtra
    anova_Omega_0 %>% kable("html", digits=2, 
        caption="Initial omega models fixed factors: Year*Region") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Omega inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "Omega mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "Omega offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega ocean", 10, 12)  
Initial omega models fixed factors: Year*Region
Sum Sq Mean Sq N Df D Df F value Pr(>F)
Omega inshore
Year 0.14 0.14 1 355.20 1.24 0.27
Sub_region 0.06 0.02 3 347.61 0.19 0.90
Year:Sub_region 0.06 0.02 3 347.61 0.19 0.90
Omega mid-channel
Year 0.30 0.30 1 333.36 5.30 0.02
Sub_region 0.13 0.04 3 323.55 0.77 0.51
Year:Sub_region 0.13 0.04 3 323.55 0.77 0.51
Omega offshore
Year 0.99 0.99 1 407.98 42.77 0.00
Sub_region 0.05 0.02 3 397.28 0.70 0.55
Year:Sub_region 0.05 0.02 3 397.28 0.69 0.56
Omega ocean
Year 0.51 0.51 1 151.92 26.14 0.00
Sub_region 0.01 0.00 2 144.15 0.15 0.86
Year:Sub_region 0.01 0.00 2 144.15 0.15 0.86
# R-ANOVAs    
    rav.Omega_in_0 <- data.frame (ranova(Omega_in_0))
    rav.Omega_mc_0 <- data.frame (ranova(Omega_mc_0) )
    rav.Omega_of_0 <- data.frame (ranova(Omega_of_0))
    rav.Omega_oc_0 <- data.frame (ranova(Omega_oc_0))
    
    # Putting all into one dataframe/table
    ranova_Omega_0 <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.Omega_in_0, rav.Omega_mc_0,
                            rav.Omega_of_0, rav.Omega_oc_0))) 
    colnames(ranova_Omega_0) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_Omega_0) <- NULL
    
    # create HTML table using kableExtra
    ranova_Omega_0 %>% kable("html", digits=2,
         caption="Initial omega models random factors: Month+Station") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Omega inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "Omega mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "Omega offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega ocean", 10, 12)  
Initial omega models random factors: Month+Station
npar logLik AIC LRT DF Pr(>Chi Sq)
Omega inshore
<none> 11 -158.47 338.94
(1 | Month) 10 -292.29 604.58 267.64 1 0.00
(1 | SiteID) 10 -159.73 339.47 2.53 1 0.11
Omega mid-channel
<none> 11 -33.11 88.21
(1 | Month) 10 -102.37 224.74 138.53 1 0.00
(1 | SiteID) 10 -33.64 87.27 1.06 1 0.30
Omega offshore
<none> 11 153.65 -285.30
(1 | Month) 10 86.50 -152.99 134.31 1 0.00
(1 | SiteID) 10 153.49 -286.97 0.33 1 0.56
Omega ocean
<none> 9 57.43 -96.87
(1 | Month) 8 28.82 -41.64 57.23 1 0.00
(1 | SiteID) 8 57.43 -98.87 0.00 1 1.00
Omega_models_0<-list("Inshore" = Omega_in_0, 
                   "Mid channel" = Omega_mc_0, 
                   "Offshore" = Omega_of_0, 
                   "Ocean" = Omega_oc_0)
modelsummary(Omega_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Initial Omega model outputs (all factors)',
             coef_map=factor_order)
Initial Omega model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year −0.021 −0.022 −0.030** −0.038**
(0.020) (0.014) (0.009) (0.013)
Intercept 45.736 48.779+ 64.605*** 80.284**
(39.883) (28.977) (18.437) (25.914)
Upper Keys −13.532 16.828 −7.316
(51.587) (40.622) (23.282)
Middle Keys −31.215 −22.537 10.487 −10.925
(50.015) (36.040) (23.075) (30.349)
Lower Keys −32.891 −35.223 −16.918 −16.583
(50.313) (36.356) (21.984) (30.572)
Num.Obs. 373 348 424 161
R2 Marg. 0.102 0.066 0.111 0.202
R2 Cond. 0.628 0.469 0.441
AIC 338.9 88.2 −285.3 −96.9
BIC 382.1 130.6 −240.8 −69.1
ICC 0.6 0.4 0.4
RMSE 0.32 0.23 0.15 0.13
+ p
#modelsummary(Omega_models, estimate = "p.value")

Models with non-significant factors removed

Omega_models<-list("Inshore" = Omega_in, 
                   "Mid channel" = Omega_mc, 
                   "Offshore" = Omega_of, 
                   "Ocean" = Omega_oc)
modelsummary(Omega_models, stars = TRUE, 
            #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Final Omega model outputs (dropped factors)',
             coef_map=factor_order)
Final Omega model outputs (dropped factors)
Inshore Mid channel Offshore Ocean
Year −0.015* −0.028*** −0.033***
(0.007) (0.004) (0.006)
Intercept 3.632*** 34.412* 59.846*** 69.403***
(0.118) (14.931) (8.611) (12.504)
Upper Keys 0.200*** 0.116** 0.020
(0.052) (0.042) (0.024)
Middle Keys 0.099+ 0.065+ 0.017
(0.051) (0.037) (0.023)
Lower Keys −0.246*** −0.085* −0.062**
(0.051) (0.037) (0.022)
Num.Obs. 373 348 424 161
R2 Marg. 0.102 0.064 0.109 0.110
R2 Cond. 0.617 0.459 0.435 0.517
AIC 308.1 64.3 −313.4 −127.6
BIC 331.7 91.3 −285.0 −115.3
ICC 0.6 0.4 0.4 0.5
RMSE 0.33 0.23 0.15 0.13
+ p
modelsummary(Omega_models, output = "FLK_results/Figures/Fig_2/Trend_Omega.docx")
#modelsummary(Omega_models, estimate = "p.value")
Trends_Omega<-ggarrange(In_Omega_Modeled+ theme(
                                          axis.text.x=element_blank(),
                                          legend.position = "none"),
                  Mc_Omega_Modeled+ theme(legend.position = "none",
                                           axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                
                  Of_Omega_Modeled + theme(legend.position = "none",
                                           #axis.title.y=element_blank(),
                                           axis.text.x=element_blank()),
                                
                  Oc_Omega_Modeled + theme(legend.position = "none",
                                           axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                           
          #labels = c("C"),
          ncol = 4, nrow = 1, widths =c(1.1, 1, 1.1, 1))
Trends_Omega

pCO2-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$pCO2_uatm
## W = 0.96584, p-value < 2.2e-16

## Model with all data
pCO2_all_o<-lmer(pCO2_uatm~Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
    step(Omega_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                    33 -319.09  704.18                         
## (1 | SiteID)          1   32 -319.34  702.67   0.49  1     0.4849    
## (1 | Month)           0   31 -506.30 1074.59 373.92  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)
## Year:Zone:Sub_region          1 0.1753 0.02192     8 1265.1  0.2644  0.97717
## Year:Sub_region               2 0.1009 0.03364     3 1273.3  0.4077  0.74747
## Year:Zone                     0 0.6658 0.22195     3 1276.1  2.6936  0.04482
## Zone:Sub_region               0 5.4769 0.68461     8 1276.1  8.3088 4.94e-11
##                         
## Year:Zone:Sub_region    
## Year:Sub_region         
## Year:Zone            *  
## Zone:Sub_region      ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone + Zone:Sub_region
pCO2_all_o_1<-lmer(pCO2_uatm ~ Year + Zone + Sub_region + (1 | Month) +
                      Year:Zone + Zone:Sub_region, data=Trends.data)

pCO2_all_o_3<-lmer(pCO2_uatm ~ Year + Zone + (1 | Month) + (1|Sub_region)+
                       Year:Zone, data=Trends.data)
    

anova(pCO2_all_o, pCO2_all_o_1, pCO2_all_o_3)
    summary(pCO2_all_o_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone +  
##     Zone:Sub_region
##    Data: Trends.data
## 
## REML criterion at convergence: 13976.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.3622 -0.5534 -0.0761  0.5213  5.6841 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 2727     52.22   
##  Residual             2721     52.17   
## Number of obs: 1306, groups:  Month, 12
## 
## Fixed effects:
##                                Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                   -2370.784   2838.709   1280.456  -0.835 0.403782
## Year                              1.394      1.407   1280.396   0.991 0.321990
## ZoneMid channel               -5726.375   3867.277   1276.066  -1.481 0.138927
## ZoneOffshore                 -10230.979   3684.011   1276.079  -2.777 0.005564
## ZoneOceanic                  -13407.538   4861.031   1275.987  -2.758 0.005896
## Sub_regionUK                    -26.986      8.171   1275.986  -3.303 0.000984
## Sub_regionMK                    -29.743      8.002   1275.980  -3.717 0.000210
## Sub_regionLK                      8.370      7.957   1275.988   1.052 0.293031
## Year:ZoneMid channel              2.828      1.916   1276.066   1.476 0.140219
## Year:ZoneOffshore                 5.059      1.826   1276.079   2.771 0.005664
## Year:ZoneOceanic                  6.629      2.409   1275.987   2.752 0.006008
## ZoneMid channel:Sub_regionUK     15.346     12.186   1275.996   1.259 0.208144
## ZoneOffshore:Sub_regionUK        22.302     11.459   1275.981   1.946 0.051846
## ZoneOceanic:Sub_regionUK         26.092     13.810   1275.998   1.889 0.059066
## ZoneMid channel:Sub_regionMK     17.202     11.313   1275.959   1.521 0.128629
## ZoneOffshore:Sub_regionMK        22.904     11.279   1275.960   2.031 0.042497
## ZoneOceanic:Sub_regionMK         32.224     11.624   1275.968   2.772 0.005651
## ZoneMid channel:Sub_regionLK     -3.244     11.259   1275.957  -0.288 0.773308
## ZoneOffshore:Sub_regionLK        -5.120     10.958   1275.960  -0.467 0.640369
##                                 
## (Intercept)                     
## Year                            
## ZoneMid channel                 
## ZoneOffshore                 ** 
## ZoneOceanic                  ** 
## Sub_regionUK                 ***
## Sub_regionMK                 ***
## Sub_regionLK                    
## Year:ZoneMid channel            
## Year:ZoneOffshore            ** 
## Year:ZoneOceanic             ** 
## ZoneMid channel:Sub_regionUK    
## ZoneOffshore:Sub_regionUK    .  
## ZoneOceanic:Sub_regionUK     .  
## ZoneMid channel:Sub_regionMK    
## ZoneOffshore:Sub_regionMK    *  
## ZoneOceanic:Sub_regionMK     ** 
## ZoneMid channel:Sub_regionLK    
## ZoneOffshore:Sub_regionLK       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## fit warnings:
## fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
    anova(pCO2_all_o_1)
    ranova(pCO2_all_o_1)
# Obtain slopes
    # ranef(pCO2_all_o_1)
    # fixef(pCO2_all_o_1)
    # coef(pCO2_all_o_1)$Month
    # coef(pCO2_all_o_1)$Zone
  m.lst <- lstrends(pCO2_all_o_1, "Zone", var="Year")
  m.lst
##  Zone        Year.trend   SE   df lower.CL upper.CL
##  Inshore           1.39 1.41 1280    -1.37     4.15
##  Mid channel       4.22 1.45 1280     1.38     7.07
##  Offshore          6.45 1.33 1280     3.85     9.05
##  Oceanic           8.02 2.05 1278     4.00    12.05
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
  pairs(m.lst)
##  contrast               estimate   SE   df t.ratio p.value
##  Inshore - Mid channel     -2.83 1.92 1276  -1.476  0.4524
##  Inshore - Offshore        -5.06 1.83 1276  -2.771  0.0289
##  Inshore - Oceanic         -6.63 2.41 1276  -2.752  0.0306
##  Mid channel - Offshore    -2.23 1.86 1276  -1.199  0.6274
##  Mid channel - Oceanic     -3.80 2.43 1276  -1.561  0.4014
##  Offshore - Oceanic        -1.57 2.36 1276  -0.664  0.9106
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 4 estimates

Inshore

# Inshore pCO2
  hist(Trends.inshore$pCO2_uatm)

  shapiro.test(Trends.inshore$pCO2_uatm)# Normality NOT? rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$pCO2_uatm
## W = 0.99227, p-value = 0.0502
  pCO2_in_0<-lmer(pCO2_uatm~Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.inshore)
  #summary(pCO2_in_0)    
  anova(pCO2_in_0)
  ranova(pCO2_in_0)
  step(pCO2_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -2081.9 4185.7                          
## (1 | Month)           0   10 -2239.1 4498.2 314.514  1    < 2e-16 ***
## (1 | SiteID)          0   10 -2084.8 4189.7   5.948  1    0.01473 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
## Year:Sub_region          1 11398.4  3799.5     3 347.47  0.9312 0.4257
## Year                     2  3465.1  3465.1     1 356.76  0.8494 0.3573
## Sub_region               3 30987.8 10329.3     3   6.99  2.5318 0.1406
## 
## Model found:
## pCO2_uatm ~ (1 | Month) + (1 | SiteID)
pCO2_in<-lmer(pCO2_uatm ~ (1|Month)+(1|SiteID), data=Trends.inshore)
  summary(pCO2_in)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 4212.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.6141 -0.6364 -0.0455  0.5782  3.8147 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 7423     86.16   
##  SiteID   (Intercept)  395     19.88   
##  Residual             4079     63.87   
## Number of obs: 373, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)    
## (Intercept)   427.28      25.82  12.22   16.55 9.77e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  anova(pCO2_in)
  plot(pCO2_in)

  par(mfrow=c(1,2))
  qqnorm(resid(pCO2_in))
  acf(resid(pCO2_in), main="acf(resid(pCO2 Inshore))")  

  par(mfrow=c(1,1))
  
  #pCO2_in.emmc<-emmeans(pCO2_in, ~Month)
      #pCO2_in.emmc<-multcomp::cld(pCO2_in.emmc)
      #pCO2_in.emmc<-pCO2_in.emmc[order(pCO2_in.emmc$Sub_region),]
      #pCO2_in.emmc
# Predict values  
  In_pCO2_Pred <- predict(pCO2_in, newdata=In_Newdata, re.form=NA, level=0, asList = FALSE)
  
  In_pCO2_Pred <-cbind(In_Newdata, In_pCO2_Pred)
  In_pCO2_Pred$Date<-as.Date(as.character(In_pCO2_Pred$Year), format = "%Y")
  
# # Model summary
#   slope<-round(
#       summary(pCO2_in)$coefficients["Year", "Estimate"], digits = 3)
#   xs <- as.Date(as.character("2018-11-20"))
#   ys <- max(Trends.midchanel$pCO2_uatm, na.rm =T)
# 
# # Plot raw data point and fitted model 
#   plot_label <- sprintf("\"\" ~ pCO[2] == %0.3f", slope)
#   plot_label2 <- expression("Year^-1")
  
  
# Plot raw data point and fitted model 
  
  In_pCO2_Modeled<-Long_plot2+
     scale_y_continuous(name=expression(paste(pCO[2], ~ " \n (", mu, " atm)")),
                        limits = c(200,800),
                        breaks = seq(0, 800, 100),  
                        expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.inshore, 
                               aes(y=pCO2_uatm, x=Date, 
                                   fill = Sub_region), 
                                  #colour = Sub_region),  
                                  alpha=0.5, size=0.5, shape=21)+
      geom_line(data=In_pCO2_Pred, aes(y = In_pCO2_Pred,
                                      x=Date), linetype=2, size=1, colour = "black")

  In_pCO2_Modeled

Mid channel

hist(Trends.midchanel$pCO2_uatm)

shapiro.test(Trends.midchanel$pCO2_uatm)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$pCO2_uatm
## W = 0.99235, p-value = 0.07115
pCO2_mc_0<-lmer(pCO2_uatm~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)
  #summary(pCO2_mc_0)    
  anova(pCO2_mc_0)
  ranova(pCO2_mc_0)
  step(pCO2_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1786.3 3594.5                          
## (1 | SiteID)          1   10 -1786.5 3592.9   0.361  1     0.5477    
## (1 | Month)           0    9 -1908.4 3834.8 243.885  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1  6492.3  2164.1     3 328.96  1.2852 0.279385   
## Year                     0 16354.6 16354.6     1 338.48  9.6873 0.002014 **
## Sub_region               0 21649.6  7216.5     3 332.02  4.2746 0.005584 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pCO2_uatm ~ Year + Sub_region + (1 | Month)
pCO2_mc<-lmer(pCO2_uatm ~ Year + Sub_region + (1 | Month), 
              data = Trends.midchanel)
   summary(pCO2_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ Year + Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3588.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8746 -0.5794 -0.1050  0.5867  4.2643 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 2567     50.66   
##  Residual             1688     41.09   
## Number of obs: 348, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)   
## (Intercept)  -7606.989   2580.295   338.502  -2.948  0.00342 **
## Year             3.979      1.279   338.483   3.112  0.00201 **
## Sub_regionUK   -11.913      7.130   332.019  -1.671  0.09570 . 
## Sub_regionMK   -12.236      6.310   331.987  -1.939  0.05331 . 
## Sub_regionLK     5.362      6.297   332.030   0.851  0.39514   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.012  0.011              
## Sub_reginMK -0.002  0.000  0.530       
## Sub_reginLK -0.018  0.017  0.532  0.601
   anova(pCO2_mc)
   plot(pCO2_mc)

   par(mfrow=c(1,2))
   qqnorm(resid(pCO2_mc))
   acf(resid(pCO2_mc), main="acf(resid(pCO2 Mid Channel))")  

   par(mfrow=c(1,1))
   
  pCO2_mc.emmc<-emmeans(pCO2_mc, ~Sub_region+Year)
        pCO2_mc.emmc<-multcomp::cld(pCO2_mc.emmc)
        pCO2_mc.emmc<-pCO2_mc.emmc[order(
          pCO2_mc.emmc$Sub_region),]
  pCO2_mc.emmc
  #write.csv(pCO2_mc.emmc, "FLK_results/Model_2_LTpCO2_POST.csv")
# Predict values  
  Mc_pCO2_Pred <- predict(pCO2_mc, newdata=Mc_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Mc_pCO2_Pred <-cbind(Mc_Newdata, Mc_pCO2_Pred)
  Mc_pCO2_Pred$Date<-as.Date(as.character(Mc_pCO2_Pred$Year), format = "%Y")
  
 # Model summary
  slope<-round(
      summary(pCO2_mc)$coefficients["Year", "Estimate"], digits = 3)
  #ys <- max(Trends.inshore$pCO2_uatm, na.rm =T)
  ys <- max(Trends.midchanel$pCO2_uatm, na.rm =T)+50

# Plot raw data point and fitted model 
  plot_label <- sprintf("\"\" ~ pCO[2] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
  
# Plot raw data point and fitted model
  Mc_pCO2_Modeled<-Long_plot2+ 
     scale_y_continuous(name=expression(paste(pCO[2], ~" (", mu, " atm)")),
                       limits = c(200,800),
                        breaks = seq(0, 800, 100),  
                        expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.midchanel, 
                               aes(y=pCO2_uatm, x=Date, 
                                   fill = Sub_region), 
                                   # colour = Sub_region),  
                               alpha=0.5, size=0.5, shape=23)+
      geom_line(data=Mc_pCO2_Pred, aes(y = Mc_pCO2_Pred,
                                      x=Date, colour = Sub_region),
                linetype=1, size=1) +
     annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Mc_pCO2_Modeled

Offshore

hist(Trends.offshore$pCO2_uatm)

shapiro.test(Trends.offshore$pCO2_uatm)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$pCO2_uatm
## W = 0.94091, p-value = 6.045e-12
pCO2_of_0<-lmer(pCO2_uatm~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(pCO2_of_0)    
  anova(pCO2_of_0)
  ranova(pCO2_of_0)
  step(pCO2_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -2035.5 4092.9                         
## (1 | SiteID)          1   10 -2035.5 4090.9   0.00  1          1    
## (1 | Month)           0    9 -2178.9 4375.8 286.89  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1   3276    1092     3 404.84  1.2925   0.27657    
## Year                     0  54912   54912     1 414.03 64.8508 8.678e-15 ***
## Sub_region               0   9100    3033     3 407.84  3.5822   0.01397 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pCO2_uatm ~ Year + Sub_region + (1 | Month)
pCO2_of<-lmer(pCO2_uatm ~ Year + Sub_region + (1 | Month),
              data =Trends.offshore)
  summary(pCO2_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 4083.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.6834 -0.6495 -0.0985  0.5935  4.4101 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 1413.8   37.6    
##  Residual              846.7   29.1    
## Number of obs: 424, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)  -1.290e+04  1.655e+03  4.141e+02  -7.798 5.16e-14 ***
## Year          6.603e+00  8.199e-01  4.140e+02   8.053 8.68e-15 ***
## Sub_regionUK -3.165e+00  4.482e+00  4.078e+02  -0.706    0.481    
## Sub_regionMK -7.104e+00  4.438e+00  4.078e+02  -1.601    0.110    
## Sub_regionLK  4.680e+00  4.220e+00  4.079e+02   1.109    0.268    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.004  0.002              
## Sub_reginMK -0.005  0.003  0.591       
## Sub_reginLK -0.014  0.012  0.623  0.630
  anova(pCO2_of)
  plot(pCO2_of)

  par(mfrow=c(1,2))
  qqnorm(resid(pCO2_of))
  acf(resid(Omega_in), main="acf(resid(pCO2 Offshore))")  

  par(mfrow=c(1,1))
  
  pCO2_of.emmc<-emmeans(pCO2_of, ~Sub_region)
        pCO2_of.emmc<-multcomp::cld(pCO2_of.emmc)
        pCO2_of.emmc<-pCO2_of.emmc[order(pCO2_of.emmc$Sub_region),]
  pCO2_of.emmc
  #write.csv(pCO2_of.emmc, "FLK_results/Model_3_LTpCO2_POST.csv")
# Predict values  
  Of_pCO2_Pred <- predict(pCO2_of, newdata=Of_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Of_pCO2_Pred <-cbind(Of_Newdata, Of_pCO2_Pred)
  Of_pCO2_Pred$Date<-as.Date(as.character(Of_pCO2_Pred$Year), format = "%Y")
  
# Model summary for slope labels 
  slope<-round(
      summary(pCO2_of)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  ys <- max(Trends.offshore$pCO2_uatm, na.rm =T) -15
  plot_label <- sprintf("\"\" ~ pCO[2] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Of_pCO2_Modeled<-Long_plot2+ 
     scale_y_continuous(name=expression(paste(pCO[2], ~" (", mu, " atm)")),
                       limits = c(300,605),
                        breaks = seq(0, 800, 100),  
                        expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.offshore, 
                               aes(y=pCO2_uatm, x=Date, 
                                   fill = Sub_region), 
                                   #colour = Sub_region),  
                                alpha=0.5, size=0.5, shape=24)+
      geom_line(data=Of_pCO2_Pred, aes(y = Of_pCO2_Pred,
                                      x=Date, colour = Sub_region),
                linetype=1, size=1) +
     annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Of_pCO2_Modeled

Oceanic

hist(Trends.ocean$pCO2_uatm)

shapiro.test(Trends.ocean$pCO2_uatm)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$pCO2_uatm
## W = 0.9089, p-value = 1.793e-08
pCO2_oc_0<-lmer(pCO2_uatm ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)
  #summary(pCO2_oc_0)    
  anova(pCO2_oc_0)
  ranova(pCO2_oc_0)
  step(pCO2_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                     9 -763.72 1545.4                         
## (1 | SiteID)          1    8 -763.72 1543.4  0.000  1          1    
## (1 | Month)           0    7 -793.09 1600.2 58.747  1  1.793e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1    77.9    39.0     2 143.41  0.0503    0.9510    
## Sub_region               2  1222.5   611.3     2 145.31  0.7992    0.4517    
## Year                     0 26011.6 26011.6     1 155.26 34.0692 3.005e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pCO2_uatm ~ Year + (1 | Month)
pCO2_oc<-lmer(pCO2_uatm ~ Year + (1 | Month), 
              data = Trends.ocean)
  summary(pCO2_oc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: 1546.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.3192 -0.6292 -0.1467  0.5901  2.8224 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 773.6    27.81   
##  Residual             763.5    27.63   
## Number of obs: 161, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept) -14025.177   2474.792    155.267  -5.667 6.87e-08 ***
## Year             7.158      1.226    155.259   5.837 3.01e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  anova(pCO2_oc) 
  plot(pCO2_oc)

  par(mfrow=c(1,2))
  qqnorm(resid(pCO2_oc))
  acf(resid(pCO2_oc), main="acf(resid(pCO2 open))")

  par(mfrow=c(1,1))
  
  pCO2_oc.emmc<-emmeans(pCO2_oc, ~Year)
        pCO2_oc.emmc<-multcomp::cld(pCO2_oc.emmc)
        #pCO2_oc.emmc<-pCO2_oc.emmc[order(pCO2_oc.emmc$Sub_region),]
  pCO2_oc.emmc
# Predict values  
  Oc_pCO2_Pred <- predict(pCO2_oc, newdata=Oc_Newdata, 
                          re.form=NA, level=0, asList = FALSE)
  Oc_pCO2_Pred <-cbind(Oc_Newdata, Oc_pCO2_Pred)
  Oc_pCO2_Pred$Date<-as.Date(as.character(Oc_pCO2_Pred$Year), format = "%Y")
  
# Model summary for slope labels 
  slope<-round(
      summary(pCO2_oc)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  ys <- max(Trends.offshore$pCO2_uatm, na.rm =T)-15
  plot_label <- sprintf("\"\" ~ pCO[2] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Oc_pCO2_Modeled<-Long_plot2+
     scale_y_continuous(name=expression(paste(pCO[2], ~" (", mu, " atm)")),
                       limits = c(300,605),
                        breaks = seq(0, 800, 100),  
                        expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.ocean, 
                               aes(y=pCO2_uatm, x=Date, 
                                   fill = Sub_region), 
                                   # colour = Sub_region),  
                                alpha=0.5, size=0.5, shape=25)+
      geom_line(data=Oc_pCO2_Pred, aes(y = Oc_pCO2_Pred, x=Date), 
                          colour = "black", linetype=1, size=1) +
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
              label =paste0(as.character(plot_label, plot_label2, sep = " ")),
              size=4)
  Oc_pCO2_Modeled

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    
    av.pCO2_in_0 <- data.frame (anova(pCO2_in_0))
    av.pCO2_mc_0 <- data.frame (anova(pCO2_mc_0) )
    av.pCO2_of_0 <- data.frame (anova(pCO2_of_0))
    av.pCO2_oc_0 <- data.frame (anova(pCO2_oc_0))
    
    # Putting all into one dataframe/table
    anova_pH <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                      rbind(av.pCO2_in_0, av.pCO2_mc_0,
                      av.pCO2_of_0, av.pCO2_oc_0))) 
    colnames(anova_pH) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_pH) <- NULL
    
    # create HTML table using kableExtra
    anova_pH %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "pCO2 inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "pCO2 mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "pCO2 offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "pCO2 ocean", 10, 12)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
pCO2 inshore
Year 3827.77 3827.77 1 353.63 0.94 0.33
Sub_region 11443.07 3814.36 3 347.47 0.93 0.42
Year:Sub_region 11398.40 3799.47 3 347.47 0.93 0.43
pCO2 mid-channel
Year 17990.76 17990.76 1 329.99 10.76 0.00
Sub_region 6574.85 2191.62 3 323.61 1.31 0.27
Year:Sub_region 6555.91 2185.30 3 323.61 1.31 0.27
pCO2 offshore
Year 56531.65 56531.65 1 410.76 66.90 0.00
Sub_region 3285.48 1095.16 3 404.76 1.30 0.28
Year:Sub_region 3276.20 1092.07 3 404.76 1.29 0.28
pCO2 ocean
Year 23313.89 23313.89 1 150.81 30.07 0.00
Sub_region 78.50 39.25 2 143.43 0.05 0.95
Year:Sub_region 77.93 38.97 2 143.44 0.05 0.95
# R-ANOVAs    
    rav.pCO2_in_0 <- data.frame (ranova(pCO2_in_0))
    rav.pCO2_mc_0 <- data.frame (ranova(pCO2_mc_0) )
    rav.pCO2_of_0 <- data.frame (ranova(pCO2_of_0))
    rav.pCO2_oc_0 <- data.frame (ranova(pCO2_oc_0))
    
    # Putting all into one dataframe/table
    ranova_pCO2 <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.pCO2_in_0, rav.pCO2_mc_0,
                            rav.pCO2_of_0, rav.pCO2_oc_0))) 
    colnames(ranova_pCO2) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_pCO2) <- NULL
    
    # create HTML table using kableExtra
    ranova_pCO2 %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Omega inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "Omega mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "Omega offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega ocean", 10, 12)  
npar logLik AIC LRT DF Pr(>Chi Sq)
Omega inshore
<none> 11 -2081.86 4185.72
(1 | Month) 10 -2239.12 4498.23 314.51 1 0.00
(1 | SiteID) 10 -2084.83 4189.66 5.95 1 0.01
Omega mid-channel
<none> 11 -1786.27 3594.53
(1 | Month) 10 -1908.39 3836.78 244.25 1 0.00
(1 | SiteID) 10 -1786.45 3592.90 0.36 1 0.55
Omega offshore
<none> 11 -2035.47 4092.93
(1 | Month) 10 -2178.91 4377.82 286.89 1 0.00
(1 | SiteID) 10 -2035.47 4090.93 0.00 1 1.00
Omega ocean
<none> 9 -763.72 1545.43
(1 | Month) 8 -793.09 1602.18 58.75 1 0.00
(1 | SiteID) 8 -763.72 1543.43 0.00 1 1.00
pCO2_models_0<-list("Inshore" = pCO2_in_0, 
                   "Mid channel" = pCO2_mc_0, 
                   "Offshore" = pCO2_of_0, 
                   "Ocean" = pCO2_oc_0)
modelsummary(pCO2_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'pCO model outputs (all factors)',
             coef_map=factor_order)
pCO model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year 3.785 5.358* 7.884*** 7.146**
(3.814) (2.472) (1.747) (2.554)
Intercept −7198.143 −10388.174* −15489.373*** −14002.744**
(7696.751) (4988.665) (3524.582) (5153.530)
Upper Keys 3479.625 −1169.721 2812.235
(9952.366) (6981.992) (4442.946)
Middle Keys −899.345 721.299 −512.538 −720.554
(9648.006) (6194.920) (4403.594) (6031.072)
Lower Keys 12648.581 9366.041 6102.617 816.985
(9705.504) (6249.496) (4195.521) (6074.571)
Num.Obs. 373 348 424 161
R2 Marg. 0.024 0.033 0.198 0.126
R2 Cond. 0.665 0.620 0.564
AIC 4185.7 3594.5 4092.9 1545.4
BIC 4228.9 3636.9 4137.5 1573.2
ICC 0.7 0.6 0.5
RMSE 61.84 39.68 28.42 26.41
+ p
#modelsummary(Omega_models, estimate = "p.value")

Factors removed models

pCO2_models<-list("Inshore" = pCO2_in, 
                   "Mid channel" = pCO2_mc, 
                   "Offshore" = pCO2_of, 
                   "Ocean" = pCO2_oc)
modelsummary(pCO2_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'pCO2 models outputs (dropped factors)',
             coef_map=factor_order)
pCO2 models outputs (dropped factors)
Inshore Mid channel Offshore Ocean
Year 3.979** 6.603*** 7.158***
(1.279) (0.820) (1.226)
Intercept 427.280*** −7606.989** −12902.943*** −14025.177***
(25.822) (2580.295) (1654.695) (2474.792)
Upper Keys −11.913+ −3.165
(7.130) (4.482)
Middle Keys −12.236+ −7.103
(6.310) (4.438)
Lower Keys 5.362 4.680
(6.297) (4.219)
Num.Obs. 373 348 424 161
R2 Marg. 0.000 0.029 0.082 0.123
R2 Cond. 0.657 0.615 0.656 0.565
AIC 4220.8 3602.4 4097.8 1554.9
BIC 4236.5 3629.4 4126.2 1567.2
ICC 0.7 0.6 0.6 0.5
RMSE 62.18 40.15 28.55 26.57
+ p
#modelsummary(pCO2_models, estimate = "p.value")
Trends_pCO2<-ggarrange(In_pCO2_Modeled+ theme(axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 legend.position = "none"),
                  Mc_pCO2_Modeled + theme(legend.position = "none",
                                 axis.title.y=element_blank(),
                                 axis.text.x=element_blank()),
                                
                  Of_pCO2_Modeled + theme(legend.position = "none",
                                           #axis.title.y=element_blank(),
                                           axis.text.x=element_blank()),
                                
                  Oc_pCO2_Modeled + theme(legend.position = "none",
                                           axis.title.y=element_blank(),
                                           axis.text.x=element_blank()),
                  
          #labels = c("A"),
          ncol = 4, nrow = 1, widths =c(1.1, 1, 1.1, 1))
Trends_pCO2

pH-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$pH_calculated
## W = 0.97877, p-value = 6.115e-13

## Model with all data
pH_all_o<-lmer(pH_calculated ~ Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
    step(pH_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                    33 2114.1 -4162.2                         
## (1 | SiteID)          1   32 2113.0 -4162.1   2.14  1     0.1432    
## (1 | Month)           0   31 1697.5 -3333.0 831.12  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated   Sum Sq   Mean Sq NumDF  DenDF F value
## Year:Zone:Sub_region          1 0.002341 0.0002926     8 1264.9  0.1612
## Year:Sub_region               2 0.010214 0.0034048     3 1273.2  1.8859
## Year:Zone                     0 0.027362 0.0091205     3 1276.0  5.0413
## Zone:Sub_region               0 0.057144 0.0071431     8 1276.0  3.9483
##                         Pr(>F)    
## Year:Zone:Sub_region 0.9956439    
## Year:Sub_region      0.1300852    
## Year:Zone            0.0017821 ** 
## Zone:Sub_region      0.0001255 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pH_calculated ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone + Zone:Sub_region
pH_all_o_1<-lmer(pH_calculated ~ Year + Zone + Sub_region + (1 | Month) +
                      Year:Zone + Zone:Sub_region, data=Trends.data)

pH_all_o_3<-lmer(pH_calculated ~ Year + Zone + (1 | Month) + (1|Sub_region)+
                       Year:Zone, data=Trends.data)
    

anova(pH_all_o, pH_all_o_1, pH_all_o_3)
    summary(pH_all_o_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone +  
##     Zone:Sub_region
##    Data: Trends.data
## 
## REML criterion at convergence: -4327.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.0984 -0.5453  0.0507  0.5325  4.6588 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.002210 0.04701 
##  Residual             0.001809 0.04253 
## Number of obs: 1306, groups:  Month, 12
## 
## Fixed effects:
##                                Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                   7.757e+00  2.315e+00  1.280e+03   3.351 0.000829
## Year                          1.329e-04  1.147e-03  1.280e+03   0.116 0.907769
## ZoneMid channel               5.458e+00  3.153e+00  1.276e+03   1.731 0.083704
## ZoneOffshore                  9.877e+00  3.004e+00  1.276e+03   3.288 0.001036
## ZoneOceanic                   1.269e+01  3.963e+00  1.276e+03   3.202 0.001399
## Sub_regionUK                  2.421e-02  6.662e-03  1.276e+03   3.634 0.000291
## Sub_regionMK                  1.660e-02  6.524e-03  1.276e+03   2.545 0.011051
## Sub_regionLK                 -2.231e-02  6.488e-03  1.276e+03  -3.438 0.000605
## Year:ZoneMid channel         -2.700e-03  1.563e-03  1.276e+03  -1.728 0.084206
## Year:ZoneOffshore            -4.889e-03  1.489e-03  1.276e+03  -3.285 0.001048
## Year:ZoneOceanic             -6.273e-03  1.964e-03  1.276e+03  -3.194 0.001439
## ZoneMid channel:Sub_regionUK -1.280e-02  9.936e-03  1.276e+03  -1.288 0.197859
## ZoneOffshore:Sub_regionUK    -2.099e-02  9.343e-03  1.276e+03  -2.247 0.024822
## ZoneOceanic:Sub_regionUK     -3.802e-02  1.126e-02  1.276e+03  -3.377 0.000755
## ZoneMid channel:Sub_regionMK -8.770e-03  9.224e-03  1.276e+03  -0.951 0.341895
## ZoneOffshore:Sub_regionMK    -1.245e-02  9.196e-03  1.276e+03  -1.354 0.175919
## ZoneOceanic:Sub_regionMK     -3.365e-02  9.478e-03  1.276e+03  -3.550 0.000398
## ZoneMid channel:Sub_regionLK  1.285e-02  9.180e-03  1.276e+03   1.400 0.161896
## ZoneOffshore:Sub_regionLK     1.862e-02  8.934e-03  1.276e+03   2.084 0.037377
##                                 
## (Intercept)                  ***
## Year                            
## ZoneMid channel              .  
## ZoneOffshore                 ** 
## ZoneOceanic                  ** 
## Sub_regionUK                 ***
## Sub_regionMK                 *  
## Sub_regionLK                 ***
## Year:ZoneMid channel         .  
## Year:ZoneOffshore            ** 
## Year:ZoneOceanic             ** 
## ZoneMid channel:Sub_regionUK    
## ZoneOffshore:Sub_regionUK    *  
## ZoneOceanic:Sub_regionUK     ***
## ZoneMid channel:Sub_regionMK    
## ZoneOffshore:Sub_regionMK       
## ZoneOceanic:Sub_regionMK     ***
## ZoneMid channel:Sub_regionLK    
## ZoneOffshore:Sub_regionLK    *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## fit warnings:
## fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
    anova(pH_all_o_1)
    ranova(pH_all_o_1)
    # ranef(pH_all_o_1)
    # fixef(pH_all_o_1)
    # coef(pH_all_o_1)$Month
    # coef(pH_all_o_1)$Zone
    m.lst <- lstrends(pH_all_o_1, "Zone", var="Year")
    m.lst
##  Zone        Year.trend      SE   df lower.CL  upper.CL
##  Inshore       0.000133 0.00115 1280 -0.00212  0.002384
##  Mid channel  -0.002567 0.00118 1279 -0.00489 -0.000247
##  Offshore     -0.004757 0.00108 1280 -0.00688 -0.002635
##  Oceanic      -0.006140 0.00167 1278 -0.00942 -0.002856
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
    pairs(m.lst)
##  contrast               estimate      SE   df t.ratio p.value
##  Inshore - Mid channel   0.00270 0.00156 1276   1.728  0.3094
##  Inshore - Offshore      0.00489 0.00149 1276   3.285  0.0058
##  Inshore - Oceanic       0.00627 0.00196 1276   3.194  0.0078
##  Mid channel - Offshore  0.00219 0.00152 1276   1.443  0.4724
##  Mid channel - Oceanic   0.00357 0.00199 1276   1.800  0.2739
##  Offshore - Oceanic      0.00138 0.00193 1276   0.718  0.8901
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 4 estimates
  # Create a new data frame for independent variables  
  Newdata<-expand.grid(Zone=unique(Trends.data$Zone),
                          Sub_region=unique(Trends.data$Sub_region),
                          Year=seq((min(Trends.data$Year)-0), (max(Trends.data$Year)+1)))
  
  # Predict values  
  pH_Pred <- predict(pH_all_o_1, newdata=Newdata, 
                        re.form=NA, level=0, asList = FALSE)
  pH_Pred <-cbind(Newdata, pH_Pred)
  pH_Pred$Date<-as.Date(as.character(pH_Pred$Year), format = "%Y")
  

pH_Modeled<-Long_plot2+ facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH[calculated])),
                       limits=c(7.80, 8.28),
                       breaks = seq(0, 10, 0.1),  
                       expand = c(0.02, 0.02)) +
      geom_point(data=Trends.data, 
                               aes(y=pH_calculated, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region),  
                                alpha=0.5, size=0.5,shape=21)+
      geom_line(data=pH_Pred, aes(y = pH_Pred, x=Date,  colour = Sub_region),
                                linetype=2, size=1) #+
      #annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
      #        label =paste0(as.character(plot_label, plot_label2, sep = " ")),
      #        size=4)
pH_Modeled

Inshore

# Inshore pH
hist(Trends.inshore$pH_calculated)

shapiro.test(Trends.inshore$pH_calculated)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$pH_calculated
## W = 0.98963, p-value = 0.009646
pH_in_0<-lmer(pH_calculated~Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID),
            data=Trends.inshore)
  #summary(pH_in_0)    
  anova(pH_in_0)
  ranova(pH_in_0)
  step(pH_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik      AIC    LRT Df Pr(>Chisq)    
## <none>                    11 518.84 -1015.68                         
## (1 | Month)           0   10 343.63  -667.26 350.42  1    < 2e-16 ***
## (1 | SiteID)          0   10 516.35 -1012.71   4.97  1    0.02574 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated   Sum Sq   Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1 0.007655 0.0025518     3 347.61  0.9699 0.40703  
## Year                     2 0.000441 0.0004414     1 356.03  0.1677 0.68239  
## Sub_region               0 0.041527 0.0138423     3   7.03  5.2711 0.03232 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pH_calculated ~ Sub_region + (1 | Month) + (1 | SiteID)
pH_in<-lmer(pH_calculated ~ Sub_region + (1 | Month) + (1 | SiteID),
            data=Trends.inshore)
  summary(pH_in)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Sub_region + (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: -1074.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8173 -0.6283 -0.0120  0.5979  3.7926 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  Month    (Intercept) 0.0057948 0.07612 
##  SiteID   (Intercept) 0.0001307 0.01143 
##  Residual             0.0026261 0.05125 
## Number of obs: 373, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##              Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)   8.02708    0.02419 14.58883 331.771   <2e-16 ***
## Sub_regionUK  0.02175    0.01317  7.02834   1.651    0.143    
## Sub_regionMK  0.01695    0.01307  6.82306   1.296    0.237    
## Sub_regionLK -0.02075    0.01305  6.77401  -1.590    0.157    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.318              
## Sub_reginMK -0.321  0.589       
## Sub_reginLK -0.322  0.590  0.595
  anova(pH_in)
  plot(pH_in)

  par(mfrow=c(1,2))
  qqnorm(resid(pH_in))
  acf(resid(pH_in), main="acf(resid(pH Inshore))")  

  par(mfrow=c(1,1))
  
  pH_in.emmc<-emmeans(pH_in, ~Sub_region)
        pH_in.emmc<-multcomp::cld(pH_in.emmc)
        pH_in.emmc<-pH_in.emmc[order(pH_in.emmc$Sub_region),]
  pH_in.emmc
#write.csv(pH_in.emmc, "FLK_results/Model_5_LTpH_POST.csv")
# Predict values  
  In_pH_Pred <- predict(pH_in, newdata=In_Newdata, 
                        re.form=NA, level=0, asList = FALSE)
  In_pH_Pred <-cbind(In_Newdata, In_pH_Pred)
  In_pH_Pred$Date<-as.Date(as.character(In_pH_Pred$Year), format = "%Y")
  
# Model summary for slope labels 
  # slope<-round(
  #     summary(pH_in)$coefficients["Year", "Estimate"], digits = 3)
  # xs <- as.Date(as.character("2018-11-20"))
  # ys <- max(Trends.inshore$pH_calculated, na.rm =T)
  # plot_label <- sprintf("\"\" ~ pH == %0.3f", slope)
  # plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  In_pH_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH)),
                       limits=c(7.80, 8.28),
                       breaks = seq(0, 10, 0.1),  
                       expand = c(0.02, 0.02)) +
      geom_point(data=Trends.inshore, 
                               aes(y=pH_calculated, x=Date, 
                                   fill = Sub_region), 
                                  #colour = Sub_region),  
                                alpha=0.5, size=0.5,shape=21)+
      geom_line(data=In_pH_Pred, aes(y = In_pH_Pred, x=Date,  colour = Sub_region),
                                linetype=2, size=1) #+
      #annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
      #        label =paste0(as.character(plot_label, plot_label2, sep = " ")),
      #        size=4)
  In_pH_Modeled

Mid channel

hist(Trends.midchanel$pH_calculated)

shapiro.test(Trends.midchanel$pH_calculated)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$pH_calculated
## W = 0.98753, p-value = 0.004369
pH_mc_0<-lmer(pH_calculated~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID),
            data=Trends.midchanel)
  #summary(pH_mc_0)    
  anova(pH_mc_0)
  ranova(pH_mc_0)
  step(pH_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik      AIC     LRT Df Pr(>Chisq)    
## <none>                    11 621.59 -1221.18                          
## (1 | SiteID)          1   10 621.36 -1222.72   0.456  1     0.4997    
## (1 | Month)           0    9 484.04  -950.08 274.647  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated    Sum Sq   Mean Sq NumDF  DenDF F value    Pr(>F)
## Year:Sub_region          1 0.0041921 0.0013974     3 328.97  1.1815 0.3167596
## Year                     0 0.0056820 0.0056820     1 337.72  4.7964 0.0292023
## Sub_region               0 0.0237637 0.0079212     3 332.00  6.6866 0.0002148
##                    
## Year:Sub_region    
## Year            *  
## Sub_region      ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pH_calculated ~ Year + Sub_region + (1 | Month)
pH_mc<-lmer(pH_calculated ~ Year + Sub_region + (1 | Month),
            data = Trends.midchanel)
  summary(pH_mc)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Year + Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: -1270
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.5029 -0.6297  0.0278  0.5480  4.0468 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.002128 0.04613 
##  Residual             0.001185 0.03442 
## Number of obs: 348, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)   12.771183   2.163374 337.738692   5.903 8.67e-09 ***
## Year          -0.002348   0.001072 337.716529  -2.190   0.0292 *  
## Sub_regionUK   0.011699   0.005973 332.002681   1.959   0.0510 .  
## Sub_regionMK   0.007645   0.005285 331.975599   1.447   0.1490    
## Sub_regionLK  -0.009538   0.005275 332.012556  -1.808   0.0715 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.012  0.011              
## Sub_reginMK -0.002  0.000  0.530       
## Sub_reginLK -0.018  0.017  0.532  0.601
  anova(pH_mc)
  plot(pH_mc)

  par(mfrow=c(1,2))
  qqnorm(resid(pH_mc))
  acf(resid(pH_mc), main="acf(resid(pH Mid Channel))")

  par(mfrow=c(1,1))
  
  pH_mc.emmc<-emmeans(pH_mc, ~Sub_region)
        pH_mc.emmc<-multcomp::cld(pH_mc.emmc)
        pH_mc.emmc<-pH_mc.emmc[order(pH_mc.emmc$Sub_region),]
  pH_mc.emmc
  #write.csv(pH_mc.emmc, "FLK_results/Model_6_LTpH_POST.csv")
# Predict values  
  Mc_pH_Pred <- predict(pH_mc, newdata=Mc_Newdata, 
                        re.form=NA, level=0, asList = FALSE)
  Mc_pH_Pred <-cbind(Mc_Newdata, Mc_pH_Pred)
  Mc_pH_Pred$Date<-as.Date(as.character(Mc_pH_Pred$Year), format = "%Y")
  
# Model summary for slope labels 
  slope<-round(
      summary(pH_mc)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  #ys <- max(Trends.inshore$pH_calculated, na.rm =T)
  ys <- max(Trends.midchanel$pH_calculated, na.rm =T)+0.03
  plot_label <- sprintf("\"\" ~ pH == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Mc_pH_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH)),
                       breaks = seq(0, 10, 0.1),  
                       limits=c(7.80, 8.28),
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.midchanel, 
                               aes(y=pH_calculated, x=Date, 
                                   fill = Sub_region), 
                                #colour = Sub_region),  
                                alpha=0.5, size=0.5, shape=23)+
      geom_line(data=Mc_pH_Pred, aes(y = Mc_pH_Pred, x=Date,  colour = Sub_region),
                                linetype=1, size=1) +
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
           label =paste0(as.character(plot_label, plot_label2, sep = " ")),
           size=4)
  Mc_pH_Modeled

Offshore

hist(Trends.offshore$pH_calculated)

shapiro.test(Trends.offshore$pH_calculated)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$pH_calculated
## W = 0.97503, p-value = 1.157e-06
pH_of_0<-lmer(pH_calculated~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(pH_of_0)    
  anova(pH_of_0)
  ranova(pH_of_0)
  step(pH_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                    11 929.90 -1837.8                         
## (1 | SiteID)          1   10 929.90 -1839.8   0.00  1          1    
## (1 | Month)           0    9 762.18 -1506.3 335.44  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated    Sum Sq   Mean Sq NumDF  DenDF F value    Pr(>F)
## Year:Sub_region          1 0.0025882 0.0008627     3 404.84  1.5961   0.18976
## Year                     0 0.0270864 0.0270864     1 413.06 49.8921 6.937e-12
## Sub_region               0 0.0057365 0.0019122     3 407.86  3.5222   0.01514
##                    
## Year:Sub_region    
## Year            ***
## Sub_region      *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pH_calculated ~ Year + Sub_region + (1 | Month)
pH_of<-lmer(pH_calculated ~ Year + Sub_region + (1 | Month), 
            data =Trends.offshore)
  summary(pH_of)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: -1888.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.0380 -0.6374  0.0984  0.6899  2.8145 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  Month    (Intercept) 0.0011248 0.03354 
##  Residual             0.0005429 0.02330 
## Number of obs: 424, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)   1.740e+01  1.326e+00  4.131e+02  13.122  < 2e-16 ***
## Year         -4.641e-03  6.571e-04  4.131e+02  -7.063 6.94e-12 ***
## Sub_regionUK  1.905e-03  3.589e-03  4.078e+02   0.531    0.596    
## Sub_regionMK  4.307e-03  3.553e-03  4.078e+02   1.212    0.226    
## Sub_regionLK -4.893e-03  3.379e-03  4.079e+02  -1.448    0.148    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.004  0.002              
## Sub_reginMK -0.005  0.003  0.591       
## Sub_reginLK -0.014  0.012  0.623  0.630
   anova(pH_of)
  plot(pH_of)

  par(mfrow=c(1,2))
  qqnorm(resid(pH_of))
  acf(resid(pH_of), main="acf(resid(pH Offshore))")

  par(mfrow=c(1,1))
  
  pH_of.emmc<-emmeans(pH_of, ~Sub_region)
        pH_of.emmc<-multcomp::cld(pH_of.emmc)
        pH_of.emmc<-pH_of.emmc[order(pH_of.emmc$Sub_region),]
  pH_of.emmc
 #write.csv(pH_of.emmc, "FLK_results/Model_7_LTpH_POST.csv")
# Predict values  
  Of_pH_Pred <- predict(pH_of, newdata=Of_Newdata, 
                        re.form=NA, level=0, asList = FALSE)
  Of_pH_Pred <-cbind(Of_Newdata, Of_pH_Pred)
  Of_pH_Pred$Date<-as.Date(as.character(Of_pH_Pred$Year), format = "%Y")

# Model summary for slope labels 
  slope<-round(
      summary(pH_of)$coefficients["Year", "Estimate"], digits = 3)
  #ys <- max(Trends.inshore$pH_calculated, na.rm =T)
  ys <- max(Trends.offshore$pH_calculated, na.rm =T)+0.08
  plot_label <- sprintf("\"\" ~ pH == %0.3f", slope)
  plot_label2 <- expression("Year^-1")  
  
# Plot raw data point and fitted model 
  Of_pH_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH)),
                      limits=c(7.88, 8.2),
                      # limits=c(7.80, 8.28),
                       breaks = seq(0, 10, 0.1),  
                       expand = c(0, 0.01)) +
    
      geom_point(data=Trends.offshore, 
                               aes(y=pH_calculated, x=Date, 
                                   fill = Sub_region), 
                                  #colour = Sub_region),  
                               alpha=0.5, size=0.5, shape=24)+
      geom_line(data=Of_pH_Pred, aes(y = Of_pH_Pred, x=Date,  colour = Sub_region),
                                linetype=1, size=1) +
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
           label =paste0(as.character(plot_label, plot_label2, sep = " ")),
           size=4)
  Of_pH_Modeled

Oceanic

hist(Trends.ocean$pH_calculated)

shapiro.test(Trends.ocean$pH_calculated)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$pH_calculated
## W = 0.94851, p-value = 1.265e-05
pH_oc_0<-lmer(pH_calculated ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)
  #summary(pH_oc_0)    
  anova(pH_oc_0)
  ranova(pH_oc_0)
  step(pH_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                     9 340.84 -663.69                         
## (1 | SiteID)          1    8 340.84 -665.69  0.000  1          1    
## (1 | Month)           0    7 306.65 -599.30 68.385  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated    Sum Sq   Mean Sq NumDF  DenDF F value    Pr(>F)
## Year:Sub_region          1 0.0000317 0.0000158     2 143.50  0.0320    0.9686
## Sub_region               2 0.0009016 0.0004508     2 145.38  0.9225    0.3998
## Year                     0 0.0132501 0.0132501     1 154.48 27.1193 6.021e-07
##                    
## Year:Sub_region    
## Sub_region         
## Year            ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pH_calculated ~ Year + (1 | Month)
pH_oc<-lmer(pH_calculated ~ Year + (1 | Month),
               data=Trends.ocean)
  summary(pH_oc)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: -719.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.6473 -0.6723  0.1239  0.6369  2.4346 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  Month    (Intercept) 0.0005838 0.02416 
##  Residual             0.0004886 0.02210 
## Number of obs: 161, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)  1.837e+01  1.984e+00  1.545e+02   9.257  < 2e-16 ***
## Year        -5.120e-03  9.832e-04  1.545e+02  -5.208 6.02e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  anova(pH_oc) 
  plot(pH_oc)

  par(mfrow=c(1,2))
  qqnorm(resid(pH_oc))
  acf(resid(pH_oc), main="acf(resid(pH ocean))")

  par(mfrow=c(1,1))
  
  pH_oc.emmc<-emmeans(pH_oc, ~Year)
        pH_oc.emmc<-multcomp::cld(pH_oc.emmc)
        #pH_oc.emmc<-pH_oc.emmc[order(pH_oc.emmc$Sub_region),]
  pH_oc.emmc
# Predict values  
  Oc_pH_Pred <- predict(pH_oc, newdata=Oc_Newdata,
                        re.form=NA, level=0, asList = FALSE)
  Oc_pH_Pred <-cbind(Oc_Newdata, Oc_pH_Pred)
  Oc_pH_Pred$Date<-as.Date(as.character(Oc_pH_Pred$Year), format = "%Y")

# Model summary for slope labels 
  slope<-round(
      summary(pH_oc)$coefficients["Year", "Estimate"], digits = 3)
  #ys <- max(Trends.inshore$pH_calculated, na.rm =T)
  ys <- max(Trends.offshore$pH_calculated, na.rm =T)+0.08
  plot_label <- sprintf("\"\" ~ pH == %0.3f", slope)
  plot_label2 <- expression("Year^-1")  
  
# Plot raw data point and fitted model 
  Oc_pH_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH)),
                      limits=c(7.88, 8.2),
                      # limits=c(7.80, 8.28),
                       breaks = seq(0, 10, 0.1),  
                       expand = c(0, 0.01)) +
    
      geom_point(data=Trends.ocean, 
                               aes(y=pH_calculated, x=Date, 
                                   fill = Sub_region), 
                                  #colour = Sub_region),  
                                alpha=0.5, size=0.5, shape=25)+
      geom_line(data=Oc_pH_Pred, aes(y = Oc_pH_Pred, x=Date),
                                linetype=1, size=1, colour = "black") +
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
           label =paste0(as.character(plot_label, plot_label2, sep = " ")),
           size=4)
  Oc_pH_Modeled

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.pH_in_0 <- data.frame (anova(pH_in_0))
    av.pH_mc_0 <- data.frame (anova(pH_mc_0) )
    av.pH_of_0 <- data.frame (anova(pH_of_0))
    av.pH_oc_0 <- data.frame (anova(pH_oc_0))
    
    # Putting all into one dataframe/table
    anova_pH <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                         rbind(av.pH_in_0, av.pH_mc_0,
                         av.pH_of_0, av.pH_oc_0))) 
    colnames(anova_pH) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_pH) <- NULL
  
  # create HTML table using kableExtra
  anova_pH %>% kable("html", digits=2) %>% 
  kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "pH inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "pH mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "pH offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "pH ocean", 10, 12)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
pH inshore
Year 0.00 0.00 1 353.00 0.31 0.58
Sub_region 0.01 0.00 3 347.61 0.97 0.40
Year:Sub_region 0.01 0.00 3 347.61 0.97 0.41
pH mid-channel
Year 0.01 0.01 1 329.23 5.72 0.02
Sub_region 0.00 0.00 3 323.64 1.21 0.31
Year:Sub_region 0.00 0.00 3 323.64 1.20 0.31
pH offshore
Year 0.03 0.03 1 409.83 52.89 0.00
Sub_region 0.00 0.00 3 404.83 1.60 0.19
Year:Sub_region 0.00 0.00 3 404.83 1.60 0.19
pH ocean
Year 0.01 0.01 1 150.07 23.63 0.00
Sub_region 0.00 0.00 2 143.50 0.03 0.97
Year:Sub_region 0.00 0.00 2 143.50 0.03 0.97
# R-ANOVAs    
    rav.pH_in_0 <- data.frame (ranova(pH_in_0))
    rav.pH_mc_0 <- data.frame (ranova(pH_mc_0) )
    rav.pH_of_0 <- data.frame (ranova(pH_of_0))
    rav.pH_oc_0 <- data.frame (ranova(pH_oc_0))
    
    # Putting all into one dataframe/table
    ranova_pH <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.pH_in_0, rav.pH_mc_0,
                            rav.pH_of_0, rav.pH_oc_0))) 
    colnames(ranova_pH) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_pH) <- NULL
    
    # create HTML table using kableExtra
    ranova_pH %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "pH inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "pH mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "pH offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "pH ocean", 10, 12)  
npar logLik AIC LRT DF Pr(>Chi Sq)
pH inshore
<none> 11 518.84 -1015.68
(1 | Month) 10 343.63 -667.26 350.42 1 0.00
(1 | SiteID) 10 516.35 -1012.71 4.97 1 0.03
pH mid-channel
<none> 11 621.59 -1221.18
(1 | Month) 10 484.04 -948.08 275.10 1 0.00
(1 | SiteID) 10 621.36 -1222.72 0.46 1 0.50
pH offshore
<none> 11 929.90 -1837.79
(1 | Month) 10 762.18 -1504.35 335.44 1 0.00
(1 | SiteID) 10 929.90 -1839.79 0.00 1 1.00
pH ocean
<none> 9 340.84 -663.69
(1 | Month) 8 306.65 -597.30 68.39 1 0.00
(1 | SiteID) 8 340.84 -665.69 0.00 1 1.00
pH_models_0<-list("Inshore" = pH_in_0, 
                   "Mid channel" = pH_mc_0, 
                   "Offshore" = pH_of_0, 
                   "Ocean" = pH_oc_0)
modelsummary(pH_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'pH model outputs (all factors)',
             coef_map=factor_order)
pH model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year −0.004 −0.004+ −0.006*** −0.005*
(0.003) (0.002) (0.001) (0.002)
Intercept 15.192* 16.018*** 20.093*** 17.934***
(6.182) (4.180) (2.820) (4.123)
Upper Keys −3.229 −0.282 −2.967
(7.992) (5.849) (3.554)
Middle Keys −5.943 −2.258 −0.158 0.921
(7.747) (5.189) (3.522) (4.822)
Lower Keys −12.466 −8.421 −5.795+ 0.039
(7.794) (5.235) (3.356) (4.856)
Num.Obs. 373 348 424 161
R2 Marg. 0.036 0.030 0.167 0.191
R2 Cond. 0.706 0.657
AIC −1015.7 −1221.2 −1837.8 −663.7
BIC −972.5 −1178.8 −1793.2 −636.0
ICC 0.7 0.6
RMSE 0.05 0.03 0.02 0.02
+ p
#modelsummary(pH_models, estimate = "p.value")

Factors removed models

pH_models<-list("Inshore" = pH_in, 
                   "Mid channel" = pH_mc, 
                   "Offshore" = pH_of, 
                   "Ocean" = pH_oc)
modelsummary(pH_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'pH model outputs (factors dropped)',
             coef_map=factor_order)
pH model outputs (factors dropped)
Inshore Mid channel Offshore Ocean
Year −0.002* −0.005*** −0.005***
(0.001) (0.001) (0.001)
Intercept 8.027*** 12.771*** 17.400*** 18.368***
(0.024) (2.163) (1.326) (1.984)
Upper Keys 0.022+ 0.012+ 0.002
(0.013) (0.006) (0.004)
Middle Keys 0.017 0.008 0.004
(0.013) (0.005) (0.004)
Lower Keys −0.021 −0.010+ −0.005
(0.013) (0.005) (0.003)
Num.Obs. 373 348 424 161
R2 Marg. 0.034 0.027 0.058 0.094
R2 Cond. 0.703 0.652 0.693 0.587
AIC −1060.4 −1256.0 −1874.8 −711.1
BIC −1033.0 −1229.1 −1846.4 −698.8
ICC 0.7 0.6 0.7 0.5
RMSE 0.05 0.03 0.02 0.02
+ p
#modelsummary(pH_models, estimate = "p.value")
Trends_pH<-ggarrange(In_pH_Modeled+ theme(axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 legend.position = "none"),
                  Mc_pH_Modeled + theme(legend.position = "none",
                                 axis.text.x=element_blank(),
                                  axis.title.y=element_blank()),
                                
                  Of_pH_Modeled + theme(legend.position = "none",
                                        #axis.title.y=element_blank(),
                                        axis.text.x=element_blank()),
                                
                  Oc_pH_Modeled + theme(legend.position = "none",
                                        axis.text.x=element_blank(),
                                        axis.title.y=element_blank()),
                  
          #labels = c("B"),
          ncol = 4, nrow = 1, widths =c(1.1, 1, 1.1, 1))
Trends_pH

dTA-All

Long_plot2<- ggplot(Reef.Trends.data) +
        MyTheme +  
        #scale_shape_manual(values=c(24, 25, 21))+
        #guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(axis.title.x = element_blank())

## 
##  Shapiro-Wilk normality test
## 
## data:  Reef.Trends.data$dTA_MY
## W = 0.82636, p-value < 2.2e-16

Inshore

# Inshore dTA
hist(Trends.inshore$dTA_MY)

shapiro.test(Trends.inshore$dTA_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$dTA_MY
## W = 0.97537, p-value = 1.479e-05
dTA_in_0<-lmer(dTA_MY ~ Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID),
             data=Trends.inshore)
  #summary(dTA_in_0)    
  anova(dTA_in_0)
  ranova(dTA_in_0)
  step(dTA_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1907.7 3837.3                          
## (1 | SiteID)          1   10 -1908.4 3836.8   1.494  1     0.2215    
## (1 | Month)           0    9 -1988.5 3995.0 160.211  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)    
## Year:Sub_region          1  24316    8105     3 320.99  1.7756 0.1517    
## Year                     2    514     514     1 334.99  0.1118 0.7383    
## Sub_region               0 521831  173944     3 325.00 37.9152 <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dTA_MY ~ Sub_region + (1 | Month)
dTA_in<-lmer(dTA_MY ~ Sub_region + (1 | Month),
             data=Trends.inshore)
  summary(dTA_in)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dTA_MY ~ Sub_region + (1 | Month)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 3840.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.5210 -0.5933  0.0214  0.5820  3.2516 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 4316     65.70   
##  Residual             4588     67.73   
## Number of obs: 340, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)    -4.420     20.788  14.432  -0.213  0.83458    
## Sub_regionUK    2.995     11.181 324.943   0.268  0.78898    
## Sub_regionMK  -34.377     10.994 324.943  -3.127  0.00193 ** 
## Sub_regionLK  -92.729     10.874 325.016  -8.527 5.74e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.305              
## Sub_reginMK -0.311  0.575       
## Sub_reginLK -0.314  0.580  0.594
  plot(dTA_in)

  par(mfrow=c(1,2))
  qqnorm(resid(dTA_in))
  acf(resid(dTA_in), main="acf(resid(dTA Inshore))")

  par(mfrow=c(1,1))
  
  dTA_in.emmc<-emmeans(dTA_in, ~Sub_region)
         dTA_in.emmc<-multcomp::cld(dTA_in.emmc)
         dTA_in.emmc<-dTA_in.emmc[order(dTA_in.emmc$Sub_region),]
  dTA_in.emmc

Mid channel

hist(Trends.midchanel$dTA_MY)

shapiro.test(Trends.midchanel$dTA_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$dTA_MY
## W = 0.84625, p-value < 2.2e-16
dTA_mc_0<-lmer(dTA_MY~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID),
             data=Trends.midchanel)
  #summary(dTA_mc_0)    
  anova(dTA_mc_0)
  ranova(dTA_mc_0)
  step(dTA_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1634.9 3291.8                         
## (1 | Month)           0   10 -1675.4 3370.9 81.063  1    < 2e-16 ***
## (1 | SiteID)          0   10 -1636.5 3293.1  3.278  1    0.07021 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  6569.9  2190.0     3 292.08  1.2103 0.30618  
## Year                     2  3291.7  3291.7     1 303.51  1.8147 0.17895  
## Sub_region               0 26984.9  8995.0     3   6.28  4.9261 0.04385 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dTA_MY ~ Sub_region + (1 | Month) + (1 | SiteID)
dTA_mc<-lmer(dTA_MY ~ (1 | Month) + (1|SiteID), 
             data = Trends.midchanel)
  summary(dTA_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dTA_MY ~ (1 | Month) + (1 | SiteID)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3319.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.9404 -0.4288  0.1101  0.5806  3.3889 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  883.6   29.73   
##  SiteID   (Intercept)  256.2   16.01   
##  Residual             1826.3   42.74   
## Number of obs: 317, groups:  Month, 12; SiteID, 10
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)
## (Intercept)   -17.91      10.28  15.93  -1.743    0.101
  plot(dTA_mc)

    par(mfrow=c(1,2))
    qqnorm(resid(dTA_mc))
    acf(resid(dTA_mc), main="acf(resid(dTA Mid Channel))") 

    par(mfrow=c(1,1))

Offshore

hist(Trends.offshore$dTA_MY)

shapiro.test(Trends.offshore$dTA_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$dTA_MY
## W = 0.82187, p-value < 2.2e-16
dTA_of_0<-lmer(dTA_MY~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(dTA_of_0)    
  anova(dTA_of_0)
  ranova(dTA_of_0)
  step(dTA_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1614.0 3249.9                         
## (1 | SiteID)          1   10 -1614.0 3247.9  0.000  1          1    
## (1 | Month)           0    9 -1638.7 3295.3 49.396  1  2.091e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  201.07   67.02     3 366.30  0.2673 0.84897  
## Year                     0 1160.22 1160.22     1 350.84  4.6547 0.03165 *
## Sub_region               0 2796.99  932.33     3 369.62  3.7404 0.01136 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dTA_MY ~ Year + Sub_region + (1 | Month)
dTA_of<-lmer(dTA_MY ~ Year + Sub_region + (1 | Month), 
             data =Trends.offshore)
  summary(dTA_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dTA_MY ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3234.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.5977 -0.3528  0.0958  0.5420  3.6581 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  72.57    8.519  
##  Residual             249.26   15.788  
## Number of obs: 386, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)  
## (Intercept)  2067.1654   959.0251  350.8053   2.155   0.0318 *
## Year           -1.0253     0.4753  350.8395  -2.157   0.0316 *
## Sub_regionUK    0.6431     2.5711  369.2325   0.250   0.8026  
## Sub_regionMK   -5.7350     2.5492  369.2510  -2.250   0.0251 *
## Sub_regionLK   -4.5279     2.4095  369.8952  -1.879   0.0610 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.008  0.007              
## Sub_reginMK -0.008  0.006  0.594       
## Sub_reginLK -0.015  0.014  0.629  0.637
  anova(dTA_of)
  plot(dTA_of)

    par(mfrow=c(1,2))
    qqnorm(resid(dTA_of))
    acf(resid(dTA_of), main="acf(resid(dTA Offshore))") 

    par(mfrow=c(1,1))
    
  dTA_of.emmc<-emmeans(dTA_of, ~Sub_region)
         dTA_of.emmc<-multcomp::cld(dTA_of.emmc)
         dTA_of.emmc<-dTA_of.emmc[order(dTA_of.emmc$Sub_region),]
  dTA_of.emmc

Models summary

dTA_models<-list("Inshore" = dTA_in, 
                   "Mid channel" = dTA_mc, 
                   "Offshore" = dTA_of)
modelsummary(dTA_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'dTA model outputs',
             coef_map=factor_order)
dTA model outputs
Inshore Mid channel Offshore
Year −1.025*
(0.475)
Intercept −4.420 −17.914+ 2067.165*
(20.788) (10.280) (959.025)
Upper Keys 2.995 0.643
(11.181) (2.571)
Middle Keys −34.377** −5.735*
(10.994) (2.549)
Lower Keys −92.729*** −4.528+
(10.874) (2.409)
Num.Obs. 340 317 386
R2 Marg. 0.149 0.000 0.036
R2 Cond. 0.562 0.384 0.254
AIC 3852.1 3327.3 3248.1
BIC 3875.1 3342.3 3275.8
ICC 0.5 0.4 0.2
RMSE 66.27 41.47 15.48
+ p
#modelsummary(dTA_models, estimate = "p.value")

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.dTA_in_0 <- data.frame (anova(dTA_in_0))
    av.dTA_mc_0 <- data.frame (anova(dTA_mc_0) )
    av.dTA_of_0 <- data.frame (anova(dTA_of_0))
    
    # Putting all into one dataframe/table
    anova_dTA <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                         rbind(av.dTA_in_0, av.dTA_mc_0,
                         av.dTA_of_0))) 
    colnames(anova_dTA) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_dTA) <- NULL
  
  # create HTML table using kableExtra
  anova_dTA %>% kable("html", digits=2) %>% 
  kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "dTA inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "dTA mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "dTA offshore", 7, 9)
Sum Sq Mean Sq N Df D Df F value Pr(>F)
dTA inshore
Year 1162.67 1162.67 1 326.11 0.26 0.61
Sub_region 24544.88 8181.63 3 314.81 1.82 0.14
Year:Sub_region 24563.77 8187.92 3 314.81 1.82 0.14
dTA mid-channel
Year 4207.52 4207.52 1 301.44 2.33 0.13
Sub_region 6571.50 2190.50 3 292.08 1.21 0.31
Year:Sub_region 6569.91 2189.97 3 292.08 1.21 0.31
dTA offshore
Year 1270.90 1270.90 1 351.50 5.07 0.02
Sub_region 201.93 67.31 3 366.29 0.27 0.85
Year:Sub_region 201.07 67.02 3 366.29 0.27 0.85
# R-ANOVAs    
    rav.dTA_in_0 <- data.frame (ranova(dTA_in_0))
    rav.dTA_mc_0 <- data.frame (ranova(dTA_mc_0) )
    rav.dTA_of_0 <- data.frame (ranova(dTA_of_0))
    
    # Putting all into one dataframe/table
    ranova_dTA <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.dTA_in_0, rav.dTA_mc_0,
                            rav.dTA_of_0))) 
    colnames(ranova_dTA) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_dTA) <- NULL
    
    # create HTML table using kableExtra
    ranova_dTA %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "dTA inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "dTA mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "dTA offshore", 7, 9)  
npar logLik AIC LRT DF Pr(>Chi Sq)
dTA inshore
<none> 11 -1907.66 3837.32
(1 | Month) 10 -1988.51 3997.02 161.71 1 0.00
(1 | SiteID) 10 -1908.41 3836.81 1.49 1 0.22
dTA mid-channel
<none> 11 -1634.90 3291.80
(1 | Month) 10 -1675.43 3370.87 81.06 1 0.00
(1 | SiteID) 10 -1636.54 3293.08 3.28 1 0.07
dTA offshore
<none> 11 -1613.96 3249.91
(1 | Month) 10 -1638.65 3297.31 49.40 1 0.00
(1 | SiteID) 10 -1613.96 3247.91 0.00 1 1.00
dTA_models_0<-list("Inshore" = dTA_in_0, 
                   "Mid channel" = dTA_mc_0, 
                   "Offshore" = dTA_of_0)
modelsummary(dTA_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'dTA model outputs (all factors)',
             coef_map=factor_order)
dTA model outputs (all factors)
Inshore Mid channel Offshore
Year −3.012 −2.750 −1.774+
(4.126) (2.653) (0.975)
Intercept 6073.297 5545.594 3577.503+
(8325.411) (5354.164) (1967.815)
Upper Keys 386.909 2122.807 −1747.945
(10557.369) (7377.147) (2452.078)
Middle Keys −17345.038+ −8051.301 −2025.940
(10238.643) (6525.399) (2429.073)
Lower Keys 1701.593 1682.953 −1722.987
(10267.968) (6560.301) (2306.156)
Num.Obs. 340 317 386
R2 Marg. 0.156 0.078 0.048
R2 Cond. 0.579 0.422
AIC 3837.3 3291.8 3249.9
BIC 3879.4 3333.2 3293.4
ICC 0.5 0.4
RMSE 64.82 41.06 15.47
+ p
#modelsummary(dTA_models, estimate = "p.value")

Factors removed models

dTA_models<-list("Inshore" = dTA_in, 
                   "Mid channel" = dTA_mc, 
                   "Offshore" = dTA_of)
modelsummary(dTA_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'TA model outputs (factors dropped)',
             coef_map=factor_order)
TA model outputs (factors dropped)
Inshore Mid channel Offshore
Year −1.025*
(0.475)
Intercept −4.420 −17.914+ 2067.165*
(20.788) (10.280) (959.025)
Upper Keys 2.995 0.643
(11.181) (2.571)
Middle Keys −34.377** −5.735*
(10.994) (2.549)
Lower Keys −92.729*** −4.528+
(10.874) (2.409)
Num.Obs. 340 317 386
R2 Marg. 0.149 0.000 0.036
R2 Cond. 0.562 0.384 0.254
AIC 3852.1 3327.3 3248.1
BIC 3875.1 3342.3 3275.8
ICC 0.5 0.4 0.2
RMSE 66.27 41.47 15.48
+ p
#modelsummary(dTA_models, estimate = "p.value")

dDIC-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Reef.Trends.data$dDIC_MY
## W = 0.87871, p-value < 2.2e-16

Inshore

# Inshore dDIC
hist(Trends.inshore$dDIC_MY)

shapiro.test(Trends.inshore$dDIC_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$dDIC_MY
## W = 0.99469, p-value = 0.2936
dDIC_in_0<-lmer(dDIC_MY~Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID), 
              data=Trends.inshore)
  #summary(dDIC_in_0)    
  anova(dDIC_in_0)
  ranova(dDIC_in_0)
  step(dDIC_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1904.2 3830.5                          
## (1 | Month)           0   10 -2019.6 4059.1 230.620  1    < 2e-16 ***
## (1 | SiteID)          0   10 -1907.0 3834.1   5.592  1    0.01804 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  25533  8511.1     3 312.67  1.8460 0.13874  
## Year                     2   1925  1925.4     1 325.59  0.4142 0.52028  
## Sub_region               0  88730 29576.7     3   7.24  6.3731 0.01943 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dDIC_MY ~ Sub_region + (1 | Month) + (1 | SiteID)
dDIC_in<-lmer(dDIC_MY ~ Sub_region + (1 | Month)+ (1 | SiteID),
              data=Trends.inshore)
  summary(dDIC_in)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dDIC_MY ~ Sub_region + (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 3832.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.3028 -0.6819  0.0077  0.6656  2.8679 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 6311.1   79.44   
##  SiteID   (Intercept)  269.4   16.41   
##  Residual             4640.9   68.12   
## Number of obs: 338, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##              Estimate Std. Error      df t value Pr(>|t|)   
## (Intercept)     9.859     27.092  16.462   0.364  0.72056   
## Sub_regionUK  -16.203     18.739   7.264  -0.865  0.41486   
## Sub_regionMK  -46.709     18.623   7.089  -2.508  0.04009 * 
## Sub_regionLK  -72.041     18.574   7.014  -3.879  0.00604 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.407              
## Sub_reginMK -0.410  0.591       
## Sub_reginLK -0.410  0.592  0.597
  plot(dDIC_in)

  par(mfrow=c(1,2))
  qqnorm(resid(dDIC_in))
  acf(resid(dDIC_in), main="acf(resid(dDIC Inshore))")

  par(mfrow=c(1,1))
  
  dDIC_in.emmc<-emmeans(dDIC_in, ~Sub_region)
         dDIC_in.emmc<-multcomp::cld(dDIC_in.emmc)
         dDIC_in.emmc<-dDIC_in.emmc[order(dDIC_in.emmc$Sub_region),]
  dDIC_in.emmc

Mid channel

hist(Trends.midchanel$dDIC_MY)

shapiro.test(Trends.midchanel$dDIC_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$dDIC_MY
## W = 0.90543, p-value = 3.815e-13
dDIC_mc_0<-lmer(dDIC_MY~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)
  #summary(dDIC_mc_0)    
  anova(dDIC_mc_0)
  ranova(dDIC_mc_0)
  step(dDIC_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1630.0 3282.0                         
## (1 | SiteID)          1   10 -1630.9 3281.9   1.85  1     0.1738    
## (1 | Month)           0    9 -1689.2 3396.3 116.45  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1   9222  3074.2     3 296.02  1.6147 0.186019   
## Year                     0  11873 11873.1     1 309.30  6.1955 0.013333 * 
## Sub_region               0  31740 10580.0     3 299.10  5.5207 0.001058 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dDIC_MY ~ Year + Sub_region + (1 | Month)
dDIC_mc<-lmer(dDIC_MY ~ Sub_region + (1 | Month),
              data = Trends.midchanel)
  summary(dDIC_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dDIC_MY ~ Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3287.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.3642 -0.4770  0.0429  0.5740  3.8569 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 1200     34.63   
##  Residual             1956     44.22   
## Number of obs: 315, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)     2.059     11.481  16.715   0.179 0.859861    
## Sub_regionUK   -9.921      8.097 300.141  -1.225 0.221439    
## Sub_regionMK  -22.716      7.179 300.116  -3.164 0.001715 ** 
## Sub_regionLK  -25.558      7.148 300.219  -3.576 0.000407 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.334              
## Sub_reginMK -0.379  0.534       
## Sub_reginLK -0.380  0.537  0.608
  plot(dDIC_mc)

  par(mfrow=c(1,2))
  qqnorm(resid(dDIC_mc))
  acf(resid(dDIC_mc), main="acf(resid(dDIC Mid Channel))")

  par(mfrow=c(1,1))
  
  dDIC_mc.emmc<-emmeans(dDIC_mc, ~Sub_region)
         dDIC_mc.emmc<-multcomp::cld(dDIC_mc.emmc)
         dDIC_mc.emmc<-dDIC_mc.emmc[order(dDIC_mc.emmc$Sub_region),]
  dDIC_mc.emmc

Offshore

hist(Trends.offshore$dDIC_MY)

shapiro.test(Trends.offshore$dDIC_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$dDIC_MY
## W = 0.78582, p-value < 2.2e-16
dDIC_of_0<-lmer(dDIC_MY~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(dDIC_of_0)    
  anova(dDIC_of_0)
  ranova(dDIC_of_0)
  step(dDIC_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1603.4 3228.9                         
## (1 | SiteID)          1   10 -1603.4 3226.9  0.000  1          1    
## (1 | Month)           0    9 -1616.4 3250.8 25.897  1  3.602e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1  974.6  324.87     3 366.36  1.3149 0.269227   
## Year                     0 2077.2 2077.25     1 280.89  8.3858 0.004079 **
## Sub_region               0 3751.7 1250.57     3 369.77  5.0485 0.001937 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dDIC_MY ~ Year + Sub_region + (1 | Month)
dDIC_of<-lmer(dDIC_MY ~ Year+ Sub_region + (1 | Month), 
              data =Trends.offshore)
  summary(dDIC_of)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dDIC_MY ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3216.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -6.2028 -0.3388  0.1296  0.5453  3.7043 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  33.24    5.765  
##  Residual             247.71   15.739  
## Number of obs: 385, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)  2687.6949   927.6272  280.8380   2.897 0.004059 ** 
## Year           -1.3312     0.4597  280.8893  -2.896 0.004079 ** 
## Sub_regionUK   -2.7375     2.5630  369.2943  -1.068 0.286173    
## Sub_regionMK   -8.6035     2.5411  369.3350  -3.386 0.000786 ***
## Sub_regionLK   -1.7183     2.4011  370.0752  -0.716 0.474676    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.008  0.006              
## Sub_reginMK -0.007  0.005  0.594       
## Sub_reginLK -0.019  0.017  0.630  0.636
  plot(dDIC_of)

  par(mfrow=c(1,2))
  qqnorm(resid(dDIC_of))
  acf(resid(dDIC_of), main="acf(resid(dDIC Offshore))") 

  par(mfrow=c(1,1))
  
  dDIC_of.emmc<-emmeans(dDIC_of, ~Sub_region+Year)
         dDIC_of.emmc<-multcomp::cld(dDIC_of.emmc)
         dDIC_of.emmc<-dDIC_of.emmc[order(dDIC_of.emmc$Sub_region),]
  dDIC_of.emmc

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.dDIC_in_0 <- data.frame (anova(dDIC_in_0))
    av.dDIC_mc_0 <- data.frame (anova(dDIC_mc_0) )
    av.dDIC_of_0 <- data.frame (anova(dDIC_of_0))
    
    # Putting all into one dataframe/table
    anova_dDIC <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                         rbind(av.dDIC_in_0, av.dDIC_mc_0,
                         av.dDIC_of_0))) 
    colnames(anova_dDIC) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_dDIC) <- NULL
  
  # create HTML table using kableExtra
  anova_dDIC %>% kable("html", digits=2) %>% 
  kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "dDIC inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "dDIC mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "dDIC offshore", 7, 9)
Sum Sq Mean Sq N Df D Df F value Pr(>F)
dDIC inshore
Year 2803.25 2803.25 1 322.49 0.61 0.44
Sub_region 25564.52 8521.51 3 312.67 1.85 0.14
Year:Sub_region 25533.26 8511.09 3 312.67 1.85 0.14
dDIC mid-channel
Year 12902.07 12902.07 1 301.75 6.91 0.01
Sub_region 9306.04 3102.01 3 290.70 1.66 0.18
Year:Sub_region 9306.19 3102.06 3 290.70 1.66 0.18
dDIC offshore
Year 1881.55 1881.55 1 287.59 7.62 0.01
Sub_region 978.21 326.07 3 366.41 1.32 0.27
Year:Sub_region 974.61 324.87 3 366.41 1.31 0.27
# R-ANOVAs    
    rav.dDIC_in_0 <- data.frame (ranova(dDIC_in_0))
    rav.dDIC_mc_0 <- data.frame (ranova(dDIC_mc_0) )
    rav.dDIC_of_0 <- data.frame (ranova(dDIC_of_0))
    
    # Putting all into one dataframe/table
    ranova_dDIC <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.dDIC_in_0, rav.dDIC_mc_0,
                            rav.dDIC_of_0))) 
    colnames(ranova_dDIC) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_dDIC) <- NULL
    
    # create HTML table using kableExtra
    ranova_dDIC %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "dDIC inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "dDIC mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "dDIC offshore", 7, 9)  
npar logLik AIC LRT DF Pr(>Chi Sq)
dDIC inshore
<none> 11 -1904.25 3830.51
(1 | Month) 10 -2019.56 4059.13 230.62 1 0.00
(1 | SiteID) 10 -1907.05 3834.10 5.59 1 0.02
dDIC mid-channel
<none> 11 -1630.01 3282.02
(1 | Month) 10 -1689.03 3398.06 118.03 1 0.00
(1 | SiteID) 10 -1630.94 3281.87 1.85 1 0.17
dDIC offshore
<none> 11 -1603.43 3228.86
(1 | Month) 10 -1616.38 3252.76 25.90 1 0.00
(1 | SiteID) 10 -1603.43 3226.86 0.00 1 1.00
dDIC_models_0<-list("Inshore" = dDIC_in_0, 
                   "Mid channel" = dDIC_mc_0, 
                   "Offshore" = dDIC_of_0)
modelsummary(dDIC_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'dDIC model outputs (all factors)',
             coef_map=factor_order)
dDIC model outputs (all factors)
Inshore Mid channel Offshore
Year −3.232 −3.772 −1.528
(4.188) (2.699) (0.961)
Intercept 6531.739 7614.228 3085.510
(8450.718) (5446.940) (1938.383)
Upper Keys 2921.375 2460.409 −314.939
(10704.340) (7491.310) (2433.857)
Middle Keys −16719.470 −7132.172 −2802.299
(10379.928) (6626.986) (2411.125)
Lower Keys 1912.774 5913.587 1199.557
(10454.070) (6691.560) (2296.660)
Num.Obs. 338 315 385
R2 Marg. 0.069 0.057 0.076
R2 Cond. 0.619 0.461
AIC 3830.5 3282.0 3228.9
BIC 3872.6 3323.3 3272.3
ICC 0.6 0.4
RMSE 65.53 41.71 15.37
+ p
#modelsummary(dDIC_models, estimate = "p.value")

Factors removed models

dDIC_models<-list("Inshore" = dDIC_in, 
                   "Mid channel" = dDIC_mc, 
                   "Offshore" = dDIC_of)
modelsummary(dDIC_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'TA model outputs (factors dropped)',
             coef_map=factor_order)
TA model outputs (factors dropped)
Inshore Mid channel Offshore
Year −1.331**
(0.460)
Intercept 9.859 2.059 2687.695**
(27.092) (11.481) (927.627)
Upper Keys −16.203 −9.921 −2.738
(18.739) (8.097) (2.563)
Middle Keys −46.709* −22.716** −8.603***
(18.623) (7.179) (2.541)
Lower Keys −72.041*** −25.558*** −1.718
(18.574) (7.148) (2.401)
Num.Obs. 338 315 385
R2 Marg. 0.063 0.031 0.059
R2 Cond. 0.612 0.399 0.171
AIC 3846.4 3299.5 3230.2
BIC 3873.2 3322.1 3257.9
ICC 0.6 0.4 0.1
RMSE 66.16 43.21 15.46
+ p
#modelsummary(dDIC_models, estimate = "p.value")

7. PCA

#str(Month_Stats)
PCA_variables<-c("DIC_mean", "TA_mean", "pCO2_mean", "Ara_mean",
              "pH_mean", "Tem_mean","Sal_mean", "Season",
              "Zone", "Sub_region", "Month2")

PCA.data<-select(Month_Stats, PCA_variables)

Name<-paste(Month_Stats$Zone, Month_Stats$Sub_region, 
            Month_Stats$Month, sep = "_")
rownames(PCA.data) <- (Name)
PCA_var.names<-c("DIC", "TA", "pCO2", "Ara",
              "pH", "Temp","Sal", "Season",
              "Zone", "Sub_region", "Month")
colnames(PCA.data) <- (PCA_var.names)
#ggpairs(PCA.data)
head(PCA.data)
library(vegan)
#library(autoplot)
library(ggfortify)

CC.rda1 <- rda(PCA.data[, -(8:11)], scale=TRUE)
CC.rda2 <- prcomp(PCA.data[, -(8:11)], scale=TRUE)
summary(CC.rda1)
## 
## Call:
## rda(X = PCA.data[, -(8:11)], scale = TRUE) 
## 
## Partitioning of correlations:
##               Inertia Proportion
## Total               7          1
## Unconstrained       7          1
## 
## Eigenvalues, and their contribution to the correlations 
## 
## Importance of components:
##                          PC1    PC2    PC3     PC4      PC5       PC6       PC7
## Eigenvalue            3.0327 2.5453 0.9904 0.42093 0.009811 5.119e-04 2.962e-04
## Proportion Explained  0.4332 0.3636 0.1415 0.06013 0.001402 7.313e-05 4.231e-05
## Cumulative Proportion 0.4332 0.7969 0.9383 0.99848 0.999885 1.000e+00 1.000e+00
## 
## Scaling 2 for species and site scores
## * Species are scaled proportional to eigenvalues
## * Sites are unscaled: weighted dispersion equal on all dimensions
## * General scaling constant of scores:  5.9496 
## 
## 
## Species scores
## 
##          PC1     PC2      PC3     PC4       PC5        PC6
## DIC  -0.5212  2.1380  0.16347  0.4292 -0.045117 -0.0339667
## TA   -1.2993  1.5552  0.76637  0.6013  0.003090  0.0324195
## pCO2  2.0840  0.7565 -0.01238  0.3339  0.172778 -0.0004344
## Ara  -0.8991 -1.4522  1.43653  0.2676  0.061471 -0.0186274
## pH   -2.1765 -0.4241  0.08535 -0.3541  0.081251  0.0010846
## Temp  1.6872 -1.0530  0.97632  0.3743 -0.085545  0.0057855
## Sal  -0.8004 -1.3827 -1.17046  1.0650  0.003909 -0.0014692
## 
## 
## Site scores (weighted sums of species scores)
## 
##                           PC1       PC2       PC3       PC4        PC5
## Inshore_BB_Jan     -0.2385073  0.868167 -0.348153 -0.177828 -0.1433937
## Inshore_BB_Feb     -0.6145657  0.442193 -0.037703 -0.403458  0.0322821
## Inshore_BB_Mar     -0.5987473  0.228733  0.177779 -0.090724  0.2331431
## Inshore_BB_Apr     -0.6158409 -0.713818  0.085971 -0.219315  0.6866287
## Inshore_BB_May     -0.5065037 -0.558873  0.351104 -0.173992  0.5487343
## Inshore_BB_Jun      0.1996849 -0.800347 -0.385244 -0.610914 -0.5722731
## Inshore_BB_Jul      0.5937217 -0.320635 -0.297686  0.638593  0.0621476
## Inshore_BB_Aug      0.6800514 -0.107492  0.240337  0.275007  0.8457504
## Inshore_BB_Sep      1.1772194  0.891409  0.421583 -0.736340  1.7859170
## Inshore_BB_Oct      1.0441996  1.146459  0.234326 -0.154260  1.6517162
## Inshore_BB_Nov      0.1831423  0.783867 -0.097901  0.281093  0.2152757
## Inshore_BB_Dec     -0.1308801  0.776228 -0.237786 -0.261322 -0.1926832
## Inshore_UK_Jan     -0.4768617  0.912308 -0.242279  0.040520  0.0777404
## Inshore_UK_Feb     -0.7935535  0.052994  0.037306 -0.512254  0.5117420
## Inshore_UK_Mar     -0.7180705 -0.063457  0.015781  0.329846  0.5601536
## Inshore_UK_Apr     -0.9204547 -1.368278  0.436382 -0.638325  2.1977685
## Inshore_UK_May     -0.7530271 -1.233331  0.278327 -0.184813  1.3663109
## Inshore_UK_Jun     -0.1175310 -0.645210  0.159807  0.057800 -0.1828506
## Inshore_UK_Jul      0.3844713 -0.319261  0.203305  0.494583  0.0312408
## Inshore_UK_Aug      0.1322017 -0.549426  0.602870  0.642088 -0.0529906
## Inshore_UK_Sep      1.1230907  0.272762  0.324150 -0.233478  0.9666269
## Inshore_UK_Oct      1.0358221  0.928163  0.190837 -0.223876  1.6053182
## Inshore_UK_Nov      0.4623045  1.218090 -0.237902  0.746794  1.6291050
## Inshore_UK_Dec     -0.1889199  0.962910 -0.248283  0.442880  0.2083250
## Inshore_MK_Jan     -0.3154977  0.963431 -0.355714  0.354506  0.1023830
## Inshore_MK_Feb     -0.8117245  0.563090  0.934039 -1.398201  0.3832079
## Inshore_MK_Mar     -0.6291832 -0.016783 -0.092036  0.589700  0.4172995
## Inshore_MK_Apr     -0.7752619 -0.975908  0.229080 -0.151963  1.3415769
## Inshore_MK_May     -0.7082246 -1.335060  0.113542 -0.216034  1.4192479
## Inshore_MK_Jun      0.0885273 -1.097764 -0.245489 -0.496840 -0.1231681
## Inshore_MK_Jul      0.8296556 -1.062703 -1.160196  0.206353 -0.3235200
## Inshore_MK_Aug      0.5210465 -0.860267 -0.472481 -0.106202 -0.5840305
## Inshore_MK_Sep      1.0358044 -0.714877 -0.875038  0.052914 -0.0015049
## Inshore_MK_Oct      0.6714491  0.496212  0.400567 -0.912255  0.3063821
## Inshore_MK_Nov      0.1673372  0.195686 -0.373351  0.217153 -0.0816679
## Inshore_MK_Dec     -0.2326569  0.943937 -0.136436 -0.006919 -0.0228416
## Inshore_LK_Jan      0.0759985  0.748062 -1.356346  0.208763  0.3928966
## Inshore_LK_Feb     -0.4615078  0.631947  0.032437 -0.655269 -0.0683949
## Inshore_LK_Mar     -0.5439031 -0.080044 -0.170756 -0.071061  0.4324108
## Inshore_LK_Apr     -0.2450027 -0.744946 -0.214420 -1.007526  0.0090844
## Inshore_LK_May     -0.0952912 -1.238306 -0.931881 -1.010681 -0.2955944
## Inshore_LK_Jun      0.4210204 -0.837485 -0.751951 -0.352754 -0.3518859
## Inshore_LK_Jul      1.1889896 -0.610795 -1.421598  0.059664  0.4318257
## Inshore_LK_Aug      1.2165368 -0.739344 -1.107791 -0.599237  0.1454002
## Inshore_LK_Sep      1.4208937 -0.340523 -0.986158 -0.650380  0.7294997
## Inshore_LK_Oct      0.9763858  0.174007 -0.637422 -0.986020  0.3183804
## Inshore_LK_Nov      0.5725780  0.384381 -1.208363  0.890782  0.7419045
## Inshore_LK_Dec      0.0421579  0.377580 -0.969812 -0.594354 -0.2042856
## Mid channel_BB_Jan -0.2693620  0.268732 -0.383841 -0.061199 -0.2334454
## Mid channel_BB_Feb -0.3614539  0.302789 -0.326854 -0.324477 -0.2232889
## Mid channel_BB_Mar -0.4549420  0.076512 -0.281244  0.174363 -0.0334081
## Mid channel_BB_Apr -0.3777877 -0.197763 -0.085269  0.114770  0.0248239
## Mid channel_BB_May -0.3376325 -0.117944  0.102259  0.321042 -0.0297005
## Mid channel_BB_Jun  0.0807324 -0.172341  0.207352 -0.061379 -0.3444000
## Mid channel_BB_Jul  0.3034605 -0.048817  0.282713  0.607994 -0.0485103
## Mid channel_BB_Aug  0.3975839 -0.167306  0.225062  0.744658  0.0106612
## Mid channel_BB_Sep  0.6805560  0.330400  0.413178 -0.531507 -0.0006482
## Mid channel_BB_Oct  0.4264616  0.357082  0.383881 -0.177934 -0.0602795
## Mid channel_BB_Nov  0.0012311  0.176331 -0.175813  0.301791 -0.0774868
## Mid channel_BB_Dec -0.1712076  0.388461 -0.268431 -0.004808 -0.2182729
## Mid channel_UK_Jan -0.4000913  0.316105 -0.189330 -0.166087 -0.1512285
## Mid channel_UK_Feb -0.4853886  0.186199 -0.164870 -0.662492 -0.1095640
## Mid channel_UK_Mar -0.5219775 -0.140922 -0.150523 -0.046481  0.2153699
## Mid channel_UK_Apr -0.5390203 -0.374065  0.235582  0.053789  0.5019248
## Mid channel_UK_May -0.6068452 -0.434017  0.353623  0.377730  0.7129567
## Mid channel_UK_Jun -0.0286638 -0.211952  0.265860  0.485900 -0.1092523
## Mid channel_UK_Jul  0.3187186 -0.096185  0.399956  0.374190 -0.1345095
## Mid channel_UK_Aug  0.0657239 -0.179864  0.687615  0.911854  0.0079616
## Mid channel_UK_Sep  0.4098357 -0.083829  0.887570 -0.302064 -0.3046529
## Mid channel_UK_Oct  0.4664904  0.352228  0.559566 -0.393484 -0.1174343
## Mid channel_UK_Nov  0.1727786  0.168503 -0.120576 -0.266751 -0.3051156
## Mid channel_UK_Dec -0.2307320  0.326385 -0.298849  0.129214 -0.1736050
## Mid channel_MK_Jan -0.2855336  0.581998 -0.292544  0.334019 -0.0533293
## Mid channel_MK_Feb -0.5152937  0.214250 -0.108007 -0.537464 -0.0519091
## Mid channel_MK_Mar -0.5897630 -0.021636 -0.189528  0.260130  0.3948362
## Mid channel_MK_Apr -0.5548833 -0.360706  0.191476  0.218128  0.3691128
## Mid channel_MK_May -0.4615923 -0.707211  0.105437  0.112138  0.5394199
## Mid channel_MK_Jun  0.1534949 -0.601058 -0.050576 -0.090768 -0.3806703
## Mid channel_MK_Jul  0.5479928 -0.569319 -0.221173  0.250673 -0.3560909
## Mid channel_MK_Aug  0.2531901 -0.491602  0.317609  0.293146 -0.3331348
## Mid channel_MK_Sep  0.8633760 -0.238198 -0.083176 -0.478088 -0.2451913
## Mid channel_MK_Oct  0.3068240  0.252867  0.621385 -0.397102 -0.2362287
## Mid channel_MK_Nov  0.0591727  0.066682 -0.053909 -0.100924 -0.2901089
## Mid channel_MK_Dec -0.1943660  0.508403 -0.285434  0.004440 -0.1163713
## Mid channel_LK_Jan  0.0464403  0.682985 -0.729027 -0.260164  0.0210800
## Mid channel_LK_Feb -0.4837384  0.496936 -0.045700 -0.313951  0.0275941
## Mid channel_LK_Mar -0.3611940  0.173627 -0.178832  0.102201 -0.0672883
## Mid channel_LK_Apr -0.1576017 -0.189570 -0.161135 -0.062944  0.3570060
## Mid channel_LK_May -0.1717066 -0.738596 -0.590703 -0.343130 -0.2543945
## Mid channel_LK_Jun  0.1607163 -0.331765 -0.106768  0.187196 -0.2751516
## Mid channel_LK_Jul  0.5182094 -0.278691 -0.076877  0.536991 -0.0576971
## Mid channel_LK_Aug  0.5783221 -0.437914 -0.092305 -0.064142 -0.3656675
## Mid channel_LK_Sep  0.8279411 -0.316452 -0.097373 -0.694902 -0.4010022
## Mid channel_LK_Oct  0.3927766  0.181096  0.363224 -0.345923 -0.2452462
## Mid channel_LK_Nov  0.1498964  0.092987 -0.256897  0.153755 -0.1347577
## Mid channel_LK_Dec -0.1697149  0.239111 -0.345585 -0.137889 -0.2327374
## Offshore_BB_Jan    -0.2101139  0.217474 -0.075341 -0.314936 -0.3030556
## Offshore_BB_Feb    -0.4033127  0.130404 -0.273020 -0.504805 -0.1801350
## Offshore_BB_Mar    -0.4222784  0.030972 -0.287781  0.168140 -0.0433538
## Offshore_BB_Apr    -0.1826034  0.086230 -0.202077  0.313490 -0.1648119
## Offshore_BB_May    -0.2077037  0.024475  0.089004  0.168942 -0.1693360
## Offshore_BB_Jun     0.1686989  0.041548  0.050786  0.446664 -0.1020688
## Offshore_BB_Jul     0.2456368 -0.007189  0.500486  0.356174 -0.1169930
## Offshore_BB_Aug     0.4763579 -0.044170  0.117945  0.850071  0.2024119
## Offshore_BB_Sep     0.4386406  0.114281  0.793550 -0.374500  0.0447616
## Offshore_BB_Oct     0.2538991  0.145290  0.629255 -0.393506 -0.3249506
## Offshore_BB_Nov    -0.1301783 -0.065160 -0.042280  0.375759 -0.1645175
## Offshore_BB_Dec    -0.1551768  0.208285 -0.157545 -0.026933 -0.2126023
## Offshore_UK_Jan    -0.2851109  0.153736 -0.238984 -0.002055 -0.2081765
## Offshore_UK_Feb    -0.4084799  0.261602 -0.249348 -0.692252 -0.2153072
## Offshore_UK_Mar    -0.3748152  0.048829 -0.282285  0.213677 -0.0998818
## Offshore_UK_Apr    -0.1935482  0.068447 -0.184221  0.244808 -0.1906348
## Offshore_UK_May    -0.2078733  0.023889 -0.030451  0.528094 -0.0984747
## Offshore_UK_Jun     0.0867225 -0.049513  0.082115  0.550785 -0.1297773
## Offshore_UK_Jul     0.2938196 -0.112046  0.362935  0.483233 -0.1182594
## Offshore_UK_Aug     0.1172148 -0.157816  0.556278  0.888595 -0.0206139
## Offshore_UK_Sep     0.3189053 -0.129103  0.857704 -0.195226 -0.2699495
## Offshore_UK_Oct     0.1654874  0.114160  0.689532 -0.442232 -0.3575945
## Offshore_UK_Nov     0.0387408 -0.014257 -0.046944  0.029043 -0.3354493
## Offshore_UK_Dec    -0.1655231  0.244966 -0.192607  0.138503 -0.1714075
## Offshore_MK_Jan    -0.2199106  0.231046 -0.306566  0.025348 -0.2443477
## Offshore_MK_Feb    -0.4417562  0.287319 -0.289649 -0.738439 -0.1756499
## Offshore_MK_Mar    -0.3622269  0.077203 -0.322310  0.273016 -0.0988588
## Offshore_MK_Apr    -0.2862646 -0.026712 -0.112848  0.228231 -0.1007927
## Offshore_MK_May    -0.1712980 -0.009522 -0.052574  0.453639 -0.0924711
## Offshore_MK_Jun    -0.0001461 -0.230571  0.173056  0.223625 -0.2451103
## Offshore_MK_Jul     0.3636412 -0.210320  0.257562  0.159898 -0.2469202
## Offshore_MK_Aug     0.1552339 -0.185422  0.530901  0.581065 -0.1331318
## Offshore_MK_Sep     0.3834768 -0.209767  0.570258 -0.428047 -0.4469248
## Offshore_MK_Oct     0.1995539  0.144636  0.726110 -0.439060 -0.3261020
## Offshore_MK_Nov    -0.1296062 -0.115604  0.155033  0.087824 -0.2443116
## Offshore_MK_Dec    -0.1822614  0.173380 -0.150205 -0.170244 -0.2292235
## Offshore_LK_Jan    -0.2594553  0.275377 -0.423050  0.028187 -0.2234522
## Offshore_LK_Feb    -0.3765376  0.394171 -0.369791 -0.776961 -0.2004630
## Offshore_LK_Mar    -0.2685311  0.043112 -0.246750  0.213659 -0.2111368
## Offshore_LK_Apr    -0.0840932  0.075201 -0.346901  0.298619 -0.0909909
## Offshore_LK_May    -0.1177668  0.017594 -0.282176  0.459080 -0.1884538
## Offshore_LK_Jun     0.1167342 -0.063040  0.025730  0.501819 -0.1726562
## Offshore_LK_Jul     0.3593151 -0.007298  0.244208  0.676010  0.0472214
## Offshore_LK_Aug     0.2978491 -0.016081  0.364640  0.670612 -0.0228916
## Offshore_LK_Sep     0.3534134 -0.060543  0.673916 -0.625378 -0.4381695
## Offshore_LK_Oct     0.2136613  0.125103  0.462917 -0.186636 -0.2984939
## Offshore_LK_Nov    -0.0529731 -0.043710 -0.086589  0.318911 -0.2249312
## Offshore_LK_Dec    -0.1861939  0.172272 -0.036436 -0.290784 -0.2220995
## Oceanic_UK_Jan     -0.1942522  0.100174 -0.087316 -0.050534 -0.2665544
## Oceanic_UK_Feb     -0.4535886  0.198882 -0.362777 -0.440944 -0.1295249
## Oceanic_UK_Mar     -0.2978396  0.002462 -0.220569 -0.070649 -0.2006281
## Oceanic_UK_Apr     -0.3049920  0.029557 -0.090544 -0.108791 -0.1789285
## Oceanic_UK_May     -0.3625028 -0.070885  0.006072  0.483866 -0.0345869
## Oceanic_UK_Jun     -0.0413330 -0.082059  0.217480  0.525613 -0.1375167
## Oceanic_UK_Jul      0.2056767 -0.116457  0.541124  0.283783 -0.1960361
## Oceanic_UK_Aug     -0.0144405 -0.096130  0.609538  1.114393  0.0743060
## Oceanic_UK_Sep      0.2056602 -0.107245  1.113690 -0.741043 -0.4118891
## Oceanic_UK_Oct      0.2334258  0.098942  0.683138 -0.314256 -0.2925670
## Oceanic_UK_Nov      0.0109500  0.027826  0.168422 -0.412926 -0.4289764
## Oceanic_UK_Dec     -0.2146449  0.122665 -0.106823  0.194055 -0.1274992
## Oceanic_MK_Jan     -0.2496400  0.160954 -0.197165 -0.053554 -0.2415330
## Oceanic_MK_Feb     -0.4487228  0.124535 -0.222252 -0.504114 -0.1081998
## Oceanic_MK_Mar     -0.2295650  0.021610 -0.253603  0.212087 -0.2045693
## Oceanic_MK_Apr     -0.1307420  0.088672 -0.245484  0.390659 -0.1356480
## Oceanic_MK_May     -0.1182698  0.110613 -0.074511  0.504925 -0.1052882
## Oceanic_MK_Jun     -0.0157905 -0.101325  0.171126  0.623804 -0.1159454
## Oceanic_MK_Jul      0.2153273 -0.076577  0.569033  0.212882 -0.1942740
## Oceanic_MK_Aug      0.1434820 -0.049292  0.606806  0.612989 -0.0749758
## Oceanic_MK_Sep      0.1409502 -0.080962  0.973938 -0.417306 -0.3443347
## Oceanic_MK_Oct      0.1800275  0.110337  0.630444 -0.028784 -0.2028290
## Oceanic_MK_Nov     -0.1705684 -0.159755  0.069815  0.452358 -0.1535793
## Oceanic_MK_Dec     -0.1492415  0.148459 -0.130697 -0.174995 -0.2419111
## Oceanic_LK_Jan     -0.2766863  0.162766 -0.353403  0.112797 -0.2004500
## Oceanic_LK_Feb     -0.4942465  0.189203 -0.320257 -0.388223 -0.0298867
## Oceanic_LK_Mar     -0.2222383 -0.005270 -0.196391  0.176255 -0.1984642
## Oceanic_LK_Apr     -0.0818029  0.099911 -0.246069  0.224361 -0.2141939
## Oceanic_LK_May     -0.1332857  0.081545 -0.178271  0.484212 -0.1685758
## Oceanic_LK_Jun      0.0157036 -0.046582  0.146664  0.580736 -0.1084621
## Oceanic_LK_Jul      0.2759892  0.029333  0.616087 -0.179151 -0.3190937
## Oceanic_LK_Aug      0.2187700 -0.011297  0.533187  0.624408 -0.1449285
## Oceanic_LK_Sep      0.1371145 -0.067844  1.118928 -0.880840 -0.4323599
## Oceanic_LK_Oct      0.1913689  0.099725  0.573190 -0.189813 -0.2948047
## Oceanic_LK_Nov     -0.1901751 -0.133077  0.198264  0.196734 -0.1867035
## Oceanic_LK_Dec     -0.1451474  0.162794  0.052444 -0.325019 -0.2653575
##                          PC6
## Inshore_BB_Jan     -0.076886
## Inshore_BB_Feb     -0.064778
## Inshore_BB_Mar     -0.018931
## Inshore_BB_Apr      0.039581
## Inshore_BB_May     -0.033477
## Inshore_BB_Jun      0.233799
## Inshore_BB_Jul     -0.003198
## Inshore_BB_Aug     -0.027948
## Inshore_BB_Sep      0.388223
## Inshore_BB_Oct      0.455479
## Inshore_BB_Nov      0.142950
## Inshore_BB_Dec      0.057731
## Inshore_UK_Jan     -0.101420
## Inshore_UK_Feb     -0.118929
## Inshore_UK_Mar      0.003456
## Inshore_UK_Apr     -0.011467
## Inshore_UK_May      0.036499
## Inshore_UK_Jun     -0.019516
## Inshore_UK_Jul     -0.170117
## Inshore_UK_Aug     -0.378867
## Inshore_UK_Sep      0.156600
## Inshore_UK_Oct      0.341671
## Inshore_UK_Nov      0.125459
## Inshore_UK_Dec      0.069949
## Inshore_MK_Jan     -0.135586
## Inshore_MK_Feb     -0.037775
## Inshore_MK_Mar     -0.011715
## Inshore_MK_Apr     -0.020640
## Inshore_MK_May      0.152478
## Inshore_MK_Jun      0.159796
## Inshore_MK_Jul      0.240048
## Inshore_MK_Aug      0.117835
## Inshore_MK_Sep      0.166382
## Inshore_MK_Oct      0.169456
## Inshore_MK_Nov      0.072652
## Inshore_MK_Dec      0.108913
## Inshore_LK_Jan     -0.752959
## Inshore_LK_Feb     -0.084416
## Inshore_LK_Mar     -0.022773
## Inshore_LK_Apr      0.154502
## Inshore_LK_May      0.350686
## Inshore_LK_Jun      0.241297
## Inshore_LK_Jul     -0.097867
## Inshore_LK_Aug     -3.396062
## Inshore_LK_Sep      0.144789
## Inshore_LK_Oct      0.124759
## Inshore_LK_Nov     -0.234097
## Inshore_LK_Dec     -0.332882
## Mid channel_BB_Jan -0.010261
## Mid channel_BB_Feb -0.027674
## Mid channel_BB_Mar  0.007491
## Mid channel_BB_Apr  0.041457
## Mid channel_BB_May  0.008505
## Mid channel_BB_Jun  0.012339
## Mid channel_BB_Jul -0.053208
## Mid channel_BB_Aug -0.115921
## Mid channel_BB_Sep  0.215543
## Mid channel_BB_Oct  0.113056
## Mid channel_BB_Nov  0.080911
## Mid channel_BB_Dec  0.053262
## Mid channel_UK_Jan -0.035255
## Mid channel_UK_Feb -0.031992
## Mid channel_UK_Mar  0.004734
## Mid channel_UK_Apr -0.062222
## Mid channel_UK_May -0.093198
## Mid channel_UK_Jun -0.080949
## Mid channel_UK_Jul -0.086911
## Mid channel_UK_Aug -0.326541
## Mid channel_UK_Sep -0.241198
## Mid channel_UK_Oct  0.084753
## Mid channel_UK_Nov  0.126251
## Mid channel_UK_Dec  0.001326
## Mid channel_MK_Jan  0.000490
## Mid channel_MK_Feb -0.028629
## Mid channel_MK_Mar -0.052112
## Mid channel_MK_Apr -0.046512
## Mid channel_MK_May  0.041466
## Mid channel_MK_Jun  0.036513
## Mid channel_MK_Jul  0.018407
## Mid channel_MK_Aug -0.152606
## Mid channel_MK_Sep  0.123453
## Mid channel_MK_Oct  0.011312
## Mid channel_MK_Nov  0.104658
## Mid channel_MK_Dec  0.029247
## Mid channel_LK_Jan -0.225125
## Mid channel_LK_Feb -0.081901
## Mid channel_LK_Mar  0.020657
## Mid channel_LK_Apr  0.005174
## Mid channel_LK_May  0.178896
## Mid channel_LK_Jun  0.085315
## Mid channel_LK_Jul  0.021072
## Mid channel_LK_Aug  4.421896
## Mid channel_LK_Sep  0.093702
## Mid channel_LK_Oct  0.058134
## Mid channel_LK_Nov  0.087031
## Mid channel_LK_Dec  0.011061
## Offshore_BB_Jan     0.056046
## Offshore_BB_Feb    -0.017034
## Offshore_BB_Mar     0.019455
## Offshore_BB_Apr     0.065233
## Offshore_BB_May     0.048677
## Offshore_BB_Jun     0.065747
## Offshore_BB_Jul    -0.124372
## Offshore_BB_Aug    -0.039726
## Offshore_BB_Sep    -0.268872
## Offshore_BB_Oct    -0.022702
## Offshore_BB_Nov     0.054486
## Offshore_BB_Dec     0.069410
## Offshore_UK_Jan     0.018053
## Offshore_UK_Feb    -0.032299
## Offshore_UK_Mar     0.024061
## Offshore_UK_Apr     0.075550
## Offshore_UK_May     0.049823
## Offshore_UK_Jun     0.015045
## Offshore_UK_Jul    -0.089073
## Offshore_UK_Aug    -0.236270
## Offshore_UK_Sep    -0.320806
## Offshore_UK_Oct    -0.066428
## Offshore_UK_Nov     0.085548
## Offshore_UK_Dec     0.055308
## Offshore_MK_Jan     0.033666
## Offshore_MK_Feb    -0.097760
## Offshore_MK_Mar     0.028433
## Offshore_MK_Apr     0.044918
## Offshore_MK_May     0.061871
## Offshore_MK_Jun    -0.011819
## Offshore_MK_Jul    -0.063469
## Offshore_MK_Aug    -0.192860
## Offshore_MK_Sep    -0.159211
## Offshore_MK_Oct    -0.082633
## Offshore_MK_Nov     0.029112
## Offshore_MK_Dec     0.053549
## Offshore_LK_Jan    -0.015492
## Offshore_LK_Feb    -0.133599
## Offshore_LK_Mar     0.270730
## Offshore_LK_Apr     0.050951
## Offshore_LK_May     0.074342
## Offshore_LK_Jun     0.038331
## Offshore_LK_Jul    -0.026761
## Offshore_LK_Aug     0.345455
## Offshore_LK_Sep    -0.113981
## Offshore_LK_Oct     0.007284
## Offshore_LK_Nov     0.072357
## Offshore_LK_Dec     0.060901
## Oceanic_UK_Jan      0.061013
## Oceanic_UK_Feb     -0.046707
## Oceanic_UK_Mar      0.044303
## Oceanic_UK_Apr      0.047837
## Oceanic_UK_May      0.035110
## Oceanic_UK_Jun     -0.015599
## Oceanic_UK_Jul     -0.149477
## Oceanic_UK_Aug     -0.250221
## Oceanic_UK_Sep     -0.455379
## Oceanic_UK_Oct     -0.079122
## Oceanic_UK_Nov      0.077288
## Oceanic_UK_Dec      0.053890
## Oceanic_MK_Jan      0.047509
## Oceanic_MK_Feb     -0.071302
## Oceanic_MK_Mar      0.058447
## Oceanic_MK_Apr      0.067668
## Oceanic_MK_May      0.061337
## Oceanic_MK_Jun     -0.005465
## Oceanic_MK_Jul     -0.153028
## Oceanic_MK_Aug     -0.201081
## Oceanic_MK_Sep     -0.365211
## Oceanic_MK_Oct     -0.098426
## Oceanic_MK_Nov      0.034684
## Oceanic_MK_Dec      0.063080
## Oceanic_LK_Jan      0.014576
## Oceanic_LK_Feb     -0.118049
## Oceanic_LK_Mar      0.059184
## Oceanic_LK_Apr      0.072873
## Oceanic_LK_May      0.072622
## Oceanic_LK_Jun      0.003400
## Oceanic_LK_Jul     -0.058420
## Oceanic_LK_Aug     -0.659513
## Oceanic_LK_Sep     -0.380837
## Oceanic_LK_Oct     -0.054803
## Oceanic_LK_Nov      0.002083
## Oceanic_LK_Dec      0.077987
# Checking if the PC axes are meaningful
eigenval <- CC.rda1$CA$eig   # Here you will get the eigenvalues
sitecoord <- CC.rda1$CA$u[,1:2]   # The site coordinates along PC1 and PC2
  eig <- data.frame(eigenval)
  eig$nb <- c(1:length(eigenval))
  eig$prop <- eig$eigenval/sum(eig$eigenval)
  eig
# (Kaiser-Guttman)
par(mfrow=c(1,2))
  barplot(eig$eigenval, main="Eigenvalues",las=2)
  abline(h=mean(eig$eigenval),col="red")    # average eigenvalue
  legend("topright","Average eigenvalue",lwd=1,col=2,bty="n")
  
  barplot(100*eig$prop,main="% of variance",las=2)

par(mfrow=c(1,1))

autoplot(CC.rda2, data = PCA.data, colour="Season", 
                shape="Sub_region",
         loadings = TRUE, loadings.colour = 'black',
         loadings.label = TRUE, loadings.label.size = 3,
         loadings.label.vjust = -1.0,
         loadings.label.colour="black",
         frame = TRUE, frame.type = 'norm')+
facet_wrap(~Zone)+MyTheme+Season_colour+Season_fill

autoplot(CC.rda2, data = PCA.data, colour="Zone", 
                shape="Sub_region",
         loadings = TRUE, loadings.colour = 'black',
         loadings.label = TRUE, loadings.label.size = 3,
         loadings.label.vjust = -1.0,
         loadings.label.colour="black",
         frame = TRUE, frame.type = 'norm')+
facet_wrap(~Season)+MyTheme

autoplot(CC.rda2, data = PCA.data, colour="Sub_region", 
                shape="Zone",
         loadings = TRUE, loadings.colour = 'black',
         loadings.label = TRUE, loadings.label.size = 3,
         loadings.label.vjust = -1.0,
         loadings.label.colour="black",
         frame = TRUE, frame.type = 'norm')+
facet_grid(~Season)+MyTheme

autoplot(CC.rda2, data = PCA.data, colour="Season", 
                shape="Zone",
         loadings = TRUE, loadings.colour = 'black',
         loadings.label = TRUE, loadings.label.size = 3,
         loadings.label.vjust = -1.0,
         loadings.label.colour="black",
         frame = TRUE, frame.type = 'norm')+
facet_wrap(~Sub_region)+MyTheme+Season_colour+Season_fill

Packages used

# Creates bibliography 
#knitr::write_bib(c(.packages()), "packages.bib")
Arel-Bundock, Vincent. 2022. Modelsummary: Summary Tables and Plots for Statistical Models and Data: Beautiful, Customizable, and Publication-Ready. https://vincentarelbundock.github.io/modelsummary/.
Arnold, Jeffrey B. 2021. Ggthemes: Extra Themes, Scales and Geoms for Ggplot2. https://github.com/jrnold/ggthemes.
Attali, Dean, and Christopher Baker. 2019. ggExtra: Add Marginal Histograms to Ggplot2, and More Ggplot2 Enhancements. https://github.com/daattali/ggExtra.
Auguie, Baptiste. 2017. gridExtra: Miscellaneous Functions for "Grid" Graphics. https://CRAN.R-project.org/package=gridExtra.
Bates, Douglas, Martin Mächler, Ben Bolker, and Steve Walker. 2015. “Fitting Linear Mixed-Effects Models Using lme4.” Journal of Statistical Software 67 (1): 1–48. https://doi.org/10.18637/jss.v067.i01.
Bates, Douglas, and Martin Maechler. 2021. Matrix: Sparse and Dense Matrix Classes and Methods. http://Matrix.R-forge.R-project.org/.
Bates, Douglas, Martin Maechler, Ben Bolker, and Steven Walker. 2021. Lme4: Linear Mixed-Effects Models Using Eigen and S4. https://github.com/lme4/lme4/.
Cheng, Joe, Bhaskar Karambelkar, and Yihui Xie. 2021. Leaflet: Create Interactive Web Maps with the JavaScript Leaflet Library. https://rstudio.github.io/leaflet/.
Grolemund, Garrett, and Hadley Wickham. 2011. “Dates and Times Made Easy with lubridate.” Journal of Statistical Software 40 (3): 1–25. https://www.jstatsoft.org/v40/i03/.
Henry, Lionel, and Hadley Wickham. 2020. Purrr: Functional Programming Tools. https://CRAN.R-project.org/package=purrr.
J, Lemon. 2006. “Plotrix: A Package in the Red Light District of r.” R-News 6 (4): 8–12.
Kassambara, Alboukadel. 2020. Ggpubr: Ggplot2 Based Publication Ready Plots. https://rpkgs.datanovia.com/ggpubr/.
Kuznetsova, Alexandra, Per B. Brockhoff, and Rune H. B. Christensen. 2017. lmerTest Package: Tests in Linear Mixed Effects Models.” Journal of Statistical Software 82 (13): 1–26. https://doi.org/10.18637/jss.v082.i13.
Kuznetsova, Alexandra, Per Bruun Brockhoff, and Rune Haubo Bojesen Christensen. 2019. lmerTest: Tests in Linear Mixed Effects Models. https://github.com/runehaubo/lmerTestR.
Legendre, Pierre. 2018. Lmodel2: Model II Regression. https://CRAN.R-project.org/package=lmodel2.
Lemon, Jim, Ben Bolker, Sander Oom, Eduardo Klein, Barry Rowlingson, Hadley Wickham, Anupam Tyagi, et al. 2021. Plotrix: Various Plotting Functions. https://CRAN.R-project.org/package=plotrix.
Lenth, Russell V. 2022. Emmeans: Estimated Marginal Means, Aka Least-Squares Means. https://github.com/rvlenth/emmeans.
Müller, Kirill, and Hadley Wickham. 2021. Tibble: Simple Data Frames. https://CRAN.R-project.org/package=tibble.
R Core Team. 2020. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.
Robinson, David, Alex Hayes, and Simon Couch. 2022. Broom: Convert Statistical Objects into Tidy Tibbles. https://CRAN.R-project.org/package=broom.
Spinu, Vitalie, Garrett Grolemund, and Hadley Wickham. 2021. Lubridate: Make Dealing with Dates a Little Easier. https://CRAN.R-project.org/package=lubridate.
Wickham, Hadley. 2007. “Reshaping Data with the reshape Package.” Journal of Statistical Software 21 (12): 1–20. http://www.jstatsoft.org/v21/i12/.
———. 2011. “The Split-Apply-Combine Strategy for Data Analysis.” Journal of Statistical Software 40 (1): 1–29. http://www.jstatsoft.org/v40/i01/.
———. 2016. Ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York. https://ggplot2.tidyverse.org.
———. 2019. Stringr: Simple, Consistent Wrappers for Common String Operations. https://CRAN.R-project.org/package=stringr.
———. 2020a. Plyr: Tools for Splitting, Applying and Combining Data. https://CRAN.R-project.org/package=plyr.
———. 2020b. Reshape2: Flexibly Reshape Data: A Reboot of the Reshape Package. https://github.com/hadley/reshape.
———. 2021a. Forcats: Tools for Working with Categorical Variables (Factors). https://CRAN.R-project.org/package=forcats.
———. 2021b. Tidyr: Tidy Messy Data. https://CRAN.R-project.org/package=tidyr.
———. 2021c. Tidyverse: Easily Install and Load the Tidyverse. https://CRAN.R-project.org/package=tidyverse.
Wickham, Hadley, Mara Averick, Jennifer Bryan, Winston Chang, Lucy D’Agostino McGowan, Romain François, Garrett Grolemund, et al. 2019. “Welcome to the tidyverse.” Journal of Open Source Software 4 (43): 1686. https://doi.org/10.21105/joss.01686.
Wickham, Hadley, Winston Chang, Lionel Henry, Thomas Lin Pedersen, Kohske Takahashi, Claus Wilke, Kara Woo, Hiroaki Yutani, and Dewey Dunnington. 2021. Ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics. https://CRAN.R-project.org/package=ggplot2.
Wickham, Hadley, Romain François, Lionel Henry, and Kirill Müller. 2021. Dplyr: A Grammar of Data Manipulation. https://CRAN.R-project.org/package=dplyr.
Wickham, Hadley, and Jim Hester. 2020. Readr: Read Rectangular Text Data. https://CRAN.R-project.org/package=readr.
Xie, Yihui. 2014. “Knitr: A Comprehensive Tool for Reproducible Research in R.” In Implementing Reproducible Computational Research, edited by Victoria Stodden, Friedrich Leisch, and Roger D. Peng. Chapman; Hall/CRC. http://www.crcpress.com/product/isbn/9781466561595.
———. 2015. Dynamic Documents with R and Knitr. 2nd ed. Boca Raton, Florida: Chapman; Hall/CRC. https://yihui.org/knitr/.
———. 2021. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.
Zhu, Hao. 2021. kableExtra: Construct Complex Table with Kable and Pipe Syntax. https://CRAN.R-project.org/package=kableExtra.